<?php
namespace Home\Controller;
use Think\Controller;

class DataController extends CommonController {
    public function test_mobile(){
        $vid = '1205';
        $post_data['task_id'] ='TASKYYS100000201807101739460661522254';
        $url = 'https://api.shujumohe.com/octopus/task.unify.query/v3?partner_code=sharedcash&partner_key=dfc99c9bad014db59fc7ed6d4187ae49';

        $result = $this->post2($url,$post_data);
        $result = json_decode($result,true);
//        var_dump($result);die;
        $data = array(
            'user_id'=>$vid,
            'mobile'=>$result['data']['task_data']['base_info']['user_number'],
            'register_time'=>strtotime($result['data']['task_data']['account_info']['net_time']),
            'net_age'=>$result['data']['task_data']['account_info']['net_age'],
            'vip_level'=>$result['data']['task_data']['account_info']['crevel'],
            'idcard'=>$result['data']['task_data']['base_info']['cert_num'],
            'score'=>$result['data']['task_data']['account_info']['credit_point'],
            'amount'=>$result['data']['task_data']['account_info']['account_balance'],
            'cert_addr'=>$result['data']['task_data']['base_info']['cert_addr'],
            'user_name'=>$result['data']['task_data']['base_info']['user_name'],
            'ctime'=>time(),
        );
//        $has_basic=M('mobile_basicinfo','',C('DB2_ZX'))->where(array('user_id'=>$vid))->getField('id');
//        if($has_basic){
//            $this->return = ['code' => '0','message'=>'success'];
//            exit;
//        }
        M('mobile_basicinfo','',C('DB2_ZX'))->add($data);
        // print_r($reportdataid);die;
        foreach ($result['data']['task_data']['bill_info'] as $key => $value) {
            $billinfodata = array(
                'user_id'=>$vid,
                'mobile'=>$result['data']['task_data']['base_info']['user_number'],
                'bill_discount'=>$result['data']['task_data']['bill_info'][$key]['bill_discount'],
                'bill_fee'=>$result['data']['task_data']['bill_info'][$key]['bill_fee'],
                'bill_cycle'=>$result['data']['task_data']['bill_info'][$key]['bill_cycle'],
                'paid_amount'=>$result['data']['task_data']['bill_info'][$key]['paid_amount'],
                'unpaid_amount'=>$result['data']['task_data']['bill_info'][$key]['unpaid_amount'],
                'breach_amount'=>$result['data']['task_data']['bill_info'][$key]['breach_amount'],
                'bill_total'=>$result['data']['task_data']['bill_info'][$key]['bill_total'],
            );
            $billinfoid = M('mobile_bill','',C('DB2_ZX'))->add($billinfodata);
            foreach ($result['data']['task_data']['bill_info'][$key]['bill_record'] as $a => $b) {
                $billrecorddata =array(
                    'billinfoid'=>$billinfoid,
                    'fee_name'=>$result['data']['task_data']['bill_info'][$key]['bill_record'][$a]['fee_name'],
                    'fee_amount'=>$result['data']['task_data']['bill_info'][$key]['bill_record'][$a]['fee_amount'],
                    'fee_category'=>$result['data']['task_data']['bill_info'][$key]['bill_record'][$a]['fee_category'],
                    'user_number'=>$result['data']['task_data']['bill_info'][$key]['bill_record'][$a]['user_number'],
                );
                $billrecorddatanum[$a] = $billrecorddata;
            }
            M('billinfo_record','',C('DB2_ZX'))->addALL($billrecorddatanum);
            $billrecorddatanum = array();
        }

        foreach ($result['data']['task_data']['payment_info'] as $g => $h) {
            $rechargedata = array(
                'mobile'=>$result['data']['task_data']['base_info']['user_number'],
                'pay_date'=>strtotime($result['data']['task_data']['payment_info'][$g]['pay_date']),
                'pay_channel'=>$result['data']['task_data']['payment_info'][$g]['pay_channel'],
                'pay_fee'=>$result['data']['task_data']['payment_info'][$g]['pay_fee'],
                'pay_type'=>$result['data']['task_data']['payment_info'][$g]['pay_type'],
            );
            $rechargedatanum[$g] = $rechargedata;
        }
        M('mobilepayment_info','',C('DB2_ZX'))->addAll($rechargedatanum);


        foreach ($result['data']['task_data']['package_info']['package_detail'] as $i => $j) {

            $package_infodata = array(
                'mobile'=>$result['data']['task_data']['base_info']['user_number'],
                'brand_name'=>$result['data']['task_data']['package_info']['brand_name'],
                'pay_type'=>$result['data']['task_data']['package_info']['pay_type'],
                'fee_cycle'=>strtotime($result['data']['task_data']['package_info']['package_detail'][$i]['fee_cycle']),
                'package_name'=>$result['data']['task_data']['package_info']['package_detail'][$i]['package_name'],
                'invalid_time'=>strtotime($result['data']['task_data']['package_info']['package_detail'][$i]['invalid_time']),
                'category'=>$result['data']['task_data']['package_info']['package_detail'][$i]['category'],
                'package_fee'=>$result['data']['task_data']['package_info']['package_detail'][$i]['package_fee'],
                'effect_time'=>strtotime($result['data']['task_data']['package_info']['package_detail'][$i]['effect_time']),
            );
            $package_detaildatanum[$i] = $package_infodata;
        }
        M('mobile_businessinfo','',	C('DB2_ZX'))->addALL($package_detaildatanum);


        foreach ($result['data']['task_data']['call_info'] as $k => $l) {
            $callinfo = array(
                'user_id' => $vid,
                'mobile'=>$result['data']['task_data']['base_info']['user_number'],
                'total_call_count'=>$result['data']['task_data']['call_info'][$k]['total_call_count'],
                'total_call_time'=>$result['data']['task_data']['call_info'][$k]['total_call_time'],
                'total_fee'=>$result['data']['task_data']['call_info'][$k]['total_fee'],
                'call_cycle'=>strtotime($result['data']['task_data']['call_info'][$k]['call_cycle']),
                'ctime'=>time(),
            );
            $callinfoid = M('call_info','',C('DB2_ZX'))->add($callinfo);
            foreach ($result['data']['task_data']['call_info'][$k]['call_record'] as $n => $m) {
                $callinforecoded = array(
                    'callinfoid'=>empty($callinfoid)?'':$callinfoid,
                    'mymobile'=>$result['data']['task_data']['base_info']['user_number'],
                    'call_cost'=>empty($result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_cost'])?'':$result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_cost'],
                    'call_land_type'=>empty($result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_land_type'])?'':$result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_land_type'],
                    'call_long_distance'=>empty($result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_long_distance'])?'0':$result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_long_distance'],
                    'call_type_name'=>empty($result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_type_name'])?'':$result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_type_name'],
                    'call_roam_cost'=>empty($result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_roam_cost'])?'0':$result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_roam_cost'],
                    'call_other_number'=>empty($result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_other_number'])?'':$result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_other_number'],
                    'call_start_time'=>empty(strtotime($result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_start_time']))?'':strtotime($result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_start_time']),
                    'call_discount'=>empty($result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_discount'])?'0':$result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_discount'],
                    'call_address'=>empty($result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_address'])?'':$result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_address'],
                    'call_time'=>empty($result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_time'])?'':$result['data']['task_data']['call_info'][$k]['call_record'][$n]['call_time'],
                );
                $callinforecodednum[$n] = $callinforecoded;
                $callinforecoded=array();
            }
            var_dump($callinforecodednum);die;
            M('mobile_callrecord_s','',C('DB2_ZX'))->addALL($callinforecodednum);

            $callinforecodednum= array();
        }
        M('user','',C('DB2'))->where(array('id'=>$vid))->setField('mobile_verify','3');
//                    $user_data = M('user','',C('DB2'))->where(array('id'=>$vid))->field('username,mobile,channel,id')->find();
//                    $channel_data = M('channel','',C('DB2'))->where(array('chan_id'=>$user_data['channel']))->field('shop_identifier,chan_id,channel_name')->find();
//                    M('apply_order','',C('DB2'))->add(array('shop_identifier'=>$channel_data['shop_identifier'],'channel_num'=>$channel_data['chan_id'],'order_num'=>date('YmdHms',time()).rand(100000,999999),'channel_name'=>$channel_data['channel_name'],'apply_user'=>$user_data['username'],'user_mobile'=>$user_data['mobile'],'apply_time'=>time(),'user_id'=>$user_data['id']));

        $this->return = ['code' => '0','message'=>'success'];
//        M('user_authentication','',C('DB2'))->where(Array('user_id'=>$vid))->save(array('mobile_state'=>'1','mobile_order_num'=>$data1['task_id']));
//        $postdata=array();
//        $postdata['user_id']=$vid;
//        $url1='https://nxyc.dstlkj.com/Data/get_data';
//        request_post($url1,$postdata);
        exit;
    }
    public function test(){
        $user_id='1184';
        $post_data['task_id'] ='TASKYYS100000201807052200130661530003';
        $post_data['contact1_mobile'] ='13957719980';
        $post_data['contact2_mobile'] ='15957721666';
        $url = 'https://api.shujumohe.com/octopus/report.task.query/v2?partner_code=sharedcash&partner_key=dfc99c9bad014db59fc7ed6d4187ae49';
        $result = $this->post2($url,$post_data);
        $result = json_decode($result,true);
        $str = base64_decode($result['data']);
        $str = gzdecode($str);
        $str = json_decode($str,true);
        $add_app['call_count_late_night_3month'] = empty($str['all_contact_stats']['call_count_late_night_3month'])?'0':$str['all_contact_stats']['call_count_late_night_3month'];
        $add_app['contact_count_mutual_3month'] = empty($str['all_contact_stats']['contact_count_mutual_3month'])?'0':$str['all_contact_stats']['contact_count_mutual_3month'];
        $add_app['call_count_call_time_less1min_6month'] = empty($str['all_contact_stats']['call_count_call_time_less1min_6month'])?'0':$str['all_contact_stats']['call_count_call_time_less1min_6month'];
        $add_app['call_count_6month'] = empty($str['all_contact_stats']['call_count_6month'])?'0':$str['all_contact_stats']['call_count_6month'];
        $add_app['contact_count_call_count_over10_6month'] = empty($str['all_contact_stats']['contact_count_call_count_over10_6month'])?'0':$str['all_contact_stats']['contact_count_call_count_over10_6month'];
        $add_app['call_count_call_time_over10min_6month'] = empty($str['all_contact_stats']['call_count_call_time_over10min_6month'])?'0':$str['all_contact_stats']['call_count_call_time_over10min_6month'];
        $add_app['call_count_active'] = empty($str['all_contact_stats_per_month']['call_count_active'])?'0':$str['all_contact_stats_per_month']['call_count_active'];
        $add_app['contact_count_active'] = empty($str['all_contact_stats_per_month']['contact_count_active'])?'0':$str['all_contact_stats_per_month']['contact_count_active'];
        $add_app['call_count_late_night'] = empty($str['all_contact_stats_per_month']['call_count_late_night'])?'0':$str['all_contact_stats_per_month']['call_count_late_night'];
        $add_app['call_count'] = empty($str['all_contact_stats_per_month']['call_count'])?'0':$str['all_contact_stats_per_month']['call_count'];
        $add_app['sex'] = $str['user_info']['gender'];
        $add_app['age'] = $str['user_info']['age'];
        $add_app['ctime'] = M('user', '', C('DB2'))->where(array('id' => $user_id))->getField('ctime');
        $add_app['td_7days'] = M('get_td_data', '', C('DB2_ZX'))->where(array('user_id' => $user_id))->getField('seven_day');
        $add_app['mobile_net_age'] = empty($str['mobile_info']['mobile_net_age'])?'0':$str['mobile_info']['mobile_net_age'];
        $add_app['consume_amount_3month'] = empty($str['carrier_consumption_stats']['consume_amount_3month'])?'0':$str['carrier_consumption_stats']['consume_amount_3month'];
        $a = json_encode($add_app,JSON_UNESCAPED_UNICODE);
        M('user_applycard', '', C('DB2'))->add($add_app);
//        $url = 'https://jallzf.miaodaoxj.com:444/xycsf/getApplyCard';
//        $res = $this->getcurl($url,$a,array('Content-type: application/json','charset:utf-8'));
//        $res = json_decode($res,true);
//        M('user','',C('DB2'))->save(array('apply_score'=>$res['data']['score'],'apply_grade'=>$res['data']['grade']));
        foreach ($str['travel_track_analysis_per_city'] as $k=>$v){
            $add = array(
                'user_id'=>$user_id,
                'arrive_city'=>$v['arrive_city'],
                'arrive_day_type'=>$v['arrive_day_type'],
                'leave_city'=>$v['leave_city'],
                'leave_day_type'=>$v['leave_day_type'],
                'arrive_day'=>strtotime($v['arrive_day']),
                'leave_day'=>strtotime($v['leave_day']),
            );
            $addnum[] = $add;
        }

        M('travel_track_analysis_per_city','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['travel_track_analysis_per_city']);
        foreach ($str['contact_area_stats_per_city'] as $k=>$v){
            $add = array(
                'user_id'=>$user_id,
                'call_count_holiday_3month'=>$v['call_count_holiday_3month'],
                'call_count_holiday_6month'=>$v['call_count_holiday_6month'],
                'contact_count_active_3month'=>$v['contact_count_active_3month'],
                'contact_count_active_6month'=>$v['contact_count_active_6month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'msg_count_3month'=>$v['msg_count_3month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'call_count_late_night_3month'=>$v['call_count_late_night_3month'],
                'contact_area_city'=>$v['contact_area_city'],
                'call_count_late_night_6month'=>$v['call_count_late_night_6month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'msg_count_6month'=>$v['msg_count_6month'],
                'contact_count_passive_6month'=>$v['contact_count_passive_6month'],
                'call_count_work_time_6month'=>$v['call_count_work_time_6month'],
                'call_count_call_time_5min10min_6month'=>$v['call_count_call_time_5min10min_6month'],
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'contact_count_passive_3month'=>$v['contact_count_passive_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
                'call_count_3month'=>$v['call_count_3month'],
                'contact_count_1month'=>$v['contact_count_1month'],
                'call_count_work_time_3month'=>$v['call_count_work_time_3month'],
                'call_count_workday_3month'=>$v['call_count_workday_3month'],
                'call_count_6month'=>$v['call_count_6month'],
                'call_count_offwork_time_3month'=>$v['call_count_offwork_time_3month'],
                'call_count_offwork_time_6month'=>$v['call_count_offwork_time_6month'],
                'contact_count_mutual_3month'=>$v['contact_count_mutual_3month'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'call_count_call_time_less1min_6month'=>$v['call_count_call_time_less1min_6month'],
                'contact_count_3month'=>$v['contact_count_3month'],
                'contact_count_call_count_over10_3month'=>$v['contact_count_call_count_over10_3month'],
                'contact_area_seq_no'=>$v['contact_area_seq_no'],
                'call_count_workday_6month'=>$v['call_count_workday_6month'],
                'contact_count_call_count_over10_6month'=>$v['contact_count_call_count_over10_6month'],
                'contact_count_6month'=>$v['contact_count_6month'],
                'contact_count_mutual_6month'=>$v['contact_count_mutual_6month'],
                'call_count_call_time_1min5min_6month'=>$v['call_count_call_time_1min5min_6month'],
            );
            $addnum[]=$add;
        }
        M('contact_area_stats_per_city','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['contact_area_stats_per_city']);
        $add  =array(
            'user_id'=>$user_id,
            'recharge_amount_3month'=>$str['carrier_consumption_stats']['recharge_amount_3month'],
            'consume_amount_1month'=>$str['carrier_consumption_stats']['consume_amount_1month'],
            'recharge_count_1month'=>$str['carrier_consumption_stats']['recharge_count_1month'],
            'recharge_amount_6month'=>$str['carrier_consumption_stats']['recharge_amount_6month'],
            'consume_amount_6month'=>$str['carrier_consumption_stats']['consume_amount_6month'],
            'recharge_count_3month'=>$str['carrier_consumption_stats']['recharge_count_3month'],
            'recharge_amount_1month'=>$str['carrier_consumption_stats']['recharge_amount_1month'],
            'consume_amount_3month'=>$str['carrier_consumption_stats']['consume_amount_3month'],
            'recharge_count_6month'=>$str['carrier_consumption_stats']['recharge_count_6month'],
        );
        M('carrier_consumption_stats','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['carrier_consumption_stats']);
        $add = array(
            'user_id'=>$user_id,
            'call_count_holiday_3month'=>$str['emergency_contact1_detail']['call_count_holiday_3month'],
            'call_count_holiday_6month'=>$str['emergency_contact1_detail']['call_count_holiday_6month'],
            'call_count_active_6month'=>$str['emergency_contact1_detail']['call_count_active_6month'],
            'call_time_3month'=>$str['emergency_contact1_detail']['call_time_3month'],
            'msg_count_3month'=>$str['emergency_contact1_detail']['msg_count_3month'],
            'call_time_passive_6month'=>$str['emergency_contact1_detail']['call_time_passive_6month'],
            'call_time_1month'=>$str['emergency_contact1_detail']['call_time_1month'],
            'call_count_active_3month'=>$str['emergency_contact1_detail']['call_count_active_3month'],
            'call_time_6month'=>$str['emergency_contact1_detail']['call_time_6month'],
            'contact_type'=>$str['emergency_contact1_detail']['contact_type'],
            'call_count_late_night_3month'=>$str['emergency_contact1_detail']['call_count_late_night_3month'],
            'call_count_late_night_6month'=>$str['emergency_contact1_detail']['call_count_late_night_6month'],
            'call_count_passive_6month'=>$str['emergency_contact1_detail']['call_count_passive_6month'],
            'call_time_active_6month'=>$str['emergency_contact1_detail']['call_time_active_6month'],
            'msg_count_6month'=>$str['emergency_contact1_detail']['msg_count_6month'],
            'call_count_work_time_6month'=>$str['emergency_contact1_detail']['call_count_work_time_6month'],
            'first_time_call_6month'=>strtotime($str['emergency_contact1_detail']['first_time_call_6month']),
            'call_time_active_3month'=>$str['emergency_contact1_detail']['call_time_active_3month'],
            'call_count_passive_3month'=>$str['emergency_contact1_detail']['call_count_passive_3month'],
            'call_count_3month'=>$str['emergency_contact1_detail']['call_count_3month'],
            'contact_name'=>$str['emergency_contact1_detail']['contact_name'],
            'contact_relation'=>$str['emergency_contact1_detail']['contact_relation'],
            'call_count_work_time_3month'=>$str['emergency_contact1_detail']['call_count_work_time_3month'],
            'call_count_workday_3month'=>$str['emergency_contact1_detail']['call_count_workday_3month'],
            'call_count_6month'=>$str['emergency_contact1_detail']['call_count_6month'],
            'call_count_offwork_time_3month'=>$str['emergency_contact1_detail']['call_count_offwork_time_3month'],
            'call_count_offwork_time_6month'=>$str['emergency_contact1_detail']['call_count_offwork_time_6month'],
            'contact_number'=>$str['emergency_contact1_detail']['contact_number'],
            'contact_area'=>$str['emergency_contact1_detail']['contact_area'],
            'call_count_1week'=>$str['emergency_contact1_detail']['call_count_1week'],
            'contact_seq_no'=>$str['emergency_contact1_detail']['contact_seq_no'],
            'is_whole_day_call_3month'=>$str['emergency_contact1_detail']['is_whole_day_call_3month'],
            'call_count_1month'=>$str['emergency_contact1_detail']['call_count_1month'],
            'call_time_passive_3month'=>$str['emergency_contact1_detail']['call_time_passive_3month'],
            'is_whole_day_call_6month'=>$str['emergency_contact1_detail']['is_whole_day_call_6month'],
            'call_count_workday_6month'=>$str['emergency_contact1_detail']['call_count_workday_6month'],
            'last_time_call_6month'=>strtotime($str['emergency_contact1_detail']['last_time_call_6month']),
            'msg_count_1month'=>$str['emergency_contact1_detail']['msg_count_1month'],
        );
        M('emergency_contact1_detail','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['emergency_contact1_detail']);
        $add = array(
            'user_id'=>$user_id,
            'call_count_holiday_3month'=>$str['emergency_contact2_detail']['call_count_holiday_3month'],
            'call_count_holiday_6month'=>$str['emergency_contact2_detail']['call_count_holiday_6month'],
            'call_count_active_6month'=>$str['emergency_contact2_detail']['call_count_active_6month'],
            'call_time_3month'=>$str['emergency_contact2_detail']['call_time_3month'],
            'msg_count_3month'=>$str['emergency_contact2_detail']['msg_count_3month'],
            'call_time_passive_6month'=>$str['emergency_contact2_detail']['call_time_passive_6month'],
            'call_time_1month'=>$str['emergency_contact2_detail']['call_time_1month'],
            'call_count_active_3month'=>$str['emergency_contact2_detail']['call_count_active_3month'],
            'call_time_6month'=>$str['emergency_contact2_detail']['call_time_6month'],
            'contact_type'=>$str['emergency_contact2_detail']['contact_type'],
            'call_count_late_night_3month'=>$str['emergency_contact2_detail']['call_count_late_night_3month'],
            'call_count_late_night_6month'=>$str['emergency_contact2_detail']['call_count_late_night_6month'],
            'call_count_passive_6month'=>$str['emergency_contact2_detail']['call_count_passive_6month'],
            'call_time_active_6month'=>$str['emergency_contact2_detail']['call_time_active_6month'],
            'msg_count_6month'=>$str['emergency_contact2_detail']['msg_count_6month'],
            'call_count_work_time_6month'=>$str['emergency_contact2_detail']['call_count_work_time_6month'],
            'first_time_call_6month'=>strtotime($str['emergency_contact2_detail']['first_time_call_6month']),
            'call_time_active_3month'=>$str['emergency_contact2_detail']['call_time_active_3month'],
            'call_count_passive_3month'=>$str['emergency_contact2_detail']['call_count_passive_3month'],
            'call_count_3month'=>$str['emergency_contact2_detail']['call_count_3month'],
            'contact_name'=>$str['emergency_contact2_detail']['contact_name'],
            'contact_relation'=>$str['emergency_contact2_detail']['contact_relation'],
            'call_count_work_time_3month'=>$str['emergency_contact2_detail']['call_count_work_time_3month'],
            'call_count_workday_3month'=>$str['emergency_contact2_detail']['call_count_workday_3month'],
            'call_count_6month'=>$str['emergency_contact2_detail']['call_count_6month'],
            'call_count_offwork_time_3month'=>$str['emergency_contact2_detail']['call_count_offwork_time_3month'],
            'call_count_offwork_time_6month'=>$str['emergency_contact2_detail']['call_count_offwork_time_6month'],
            'contact_number'=>$str['emergency_contact2_detail']['contact_number'],
            'contact_area'=>$str['emergency_contact2_detail']['contact_area'],
            'call_count_1week'=>$str['emergency_contact2_detail']['call_count_1week'],
            'contact_seq_no'=>$str['emergency_contact2_detail']['contact_seq_no'],
            'is_whole_day_call_3month'=>$str['emergency_contact2_detail']['is_whole_day_call_3month'],
            'call_count_1month'=>$str['emergency_contact2_detail']['call_count_1month'],
            'call_time_passive_3month'=>$str['emergency_contact2_detail']['call_time_passive_3month'],
            'is_whole_day_call_6month'=>$str['emergency_contact2_detail']['is_whole_day_call_6month'],
            'call_count_workday_6month'=>$str['emergency_contact2_detail']['call_count_workday_6month'],
            'last_time_call_6month'=>strtotime($str['emergency_contact2_detail']['last_time_call_6month']),
            'msg_count_1month'=>$str['emergency_contact2_detail']['msg_count_1month'],
        );
        M('emergency_contact1_detail','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['emergency_contact2_detail']);
        foreach ($str['carrier_consumption_stats_per_month'] as $k=>$v){
            $add = array(
                'user_id'=>$user_id,
                'consume_amount'=>$v['consume_amount'],
                'recharge_amount'=>$v['recharge_amount'],
                'month'=>strtotime($v['month']),
                'recharge_count'=>$v['recharge_count'],
            );
            $addnum[]=$add;
        }
        M('carrier_consumption_stats_per_month','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['carrier_consumption_stats_per_month']);
        foreach ($str['finance_contact_stats'] as $k=>$v){
            $add = array(
                'user_id'=>$user_id,
                'call_count_3month'=>$v['call_count_3month'],
                'contact_count_1month'=>$v['contact_count_1month'],
                'call_count_6month'=>$v['call_count_6month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'msg_count_3month'=>$v['msg_count_3month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'contact_type'=>$v['contact_type'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'msg_count_6month'=>$v['msg_count_6month'],
                'contact_count_3month'=>$v['contact_count_3month'],
                'contact_count_6month'=>$v['contact_count_6month'],
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
            );
            $addnum[]=$add;
        }
        M('finance_contact_stats','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['finance_contact_stats']);
        $add = array(
            'user_id'=>$user_id,
            'emergency_contact3_analysis_6month'=>$str['behavior_analysis']['emergency_contact3_analysis_6month'],
            'late_night_analysis_6month'=>$str['behavior_analysis']['late_night_analysis_6month'],
            'call_120_analysis_6month'=>$str['behavior_analysis']['call_120_analysis_6month'],
            'emergency_contact4_analysis_6month'=>$str['behavior_analysis']['emergency_contact4_analysis_6month'],
            'call_lawyer_analysis_6month'=>$str['behavior_analysis']['call_lawyer_analysis_6month'],
            'emergency_contact2_analysis_6month'=>$str['behavior_analysis']['emergency_contact2_analysis_6month'],
            'mutual_number_analysis_6month'=>$str['behavior_analysis']['mutual_number_analysis_6month'],
            'loan_contact_analysis_6month'=>$str['behavior_analysis']['loan_contact_analysis_6month'],
            'emergency_contact5_analysis_6month'=>$str['behavior_analysis']['emergency_contact5_analysis_6month'],
            'emergency_contact1_analysis_6month'=>$str['behavior_analysis']['emergency_contact1_analysis_6month'],
            'collection_contact_analysis_6month'=>$str['behavior_analysis']['collection_contact_analysis_6month'],
            'call_110_analysis_6month'=>$str['behavior_analysis']['call_110_analysis_6month'],
            'mobile_net_age_analysis'=>$str['behavior_analysis']['mobile_net_age_analysis'],
            'mobile_silence_analysis_6month'=>$str['behavior_analysis']['mobile_silence_analysis_6month'],
            'call_macau_analysis_6month'=>$str['behavior_analysis']['call_macau_analysis_6month'],
        );
        M('behavior_analysis','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['behavior_analysis']);
        foreach ($str['risk_contact_detail'] as $k=>$v){
            $add = array(
                'user_id'=>$user_id,
                'call_count_holiday_3month'=>$v['call_count_holiday_3month'],
                'call_count_holiday_6month'=>$v['call_count_holiday_6month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'msg_count_3month'=>$v['msg_count_3month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'contact_type'=>$v['contact_type'],
                'call_count_late_night_3month'=>$v['call_count_late_night_3month'],
                'call_count_late_night_6month'=>$v['call_count_late_night_6month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'msg_count_6month'=>$v['msg_count_6month'],
                'call_count_work_time_6month'=>$v['call_count_work_time_6month'],
                'first_time_call_6month'=>strtotime($v['first_time_call_6month']),
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
                'call_count_3month'=>$v['call_count_3month'],
                'contact_name'=>$v['contact_name'],
                'contact_relation'=>$v['contact_relation'],
                'call_count_work_time_3month'=>$v['call_count_work_time_3month'],
                'call_count_workday_3month'=>$v['call_count_workday_3month'],
                'call_count_6month'=>$v['call_count_6month'],
                'call_count_offwork_time_3month'=>$v['call_count_offwork_time_3month'],
                'call_count_offwork_time_6month'=>$v['call_count_offwork_time_6month'],
                'contact_number'=>$v['contact_number'],
                'contact_area'=>$v['contact_area'],
                'call_count_1week'=>$v['call_count_1week'],
                'contact_seq_no'=>$v['contact_seq_no'],
                'is_whole_day_call_3month'=>$v['is_whole_day_call_3month'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'is_whole_day_call_6month'=>$v['is_whole_day_call_6month'],
                'call_count_workday_6month'=>$v['call_count_workday_6month'],
                'last_time_call_6month'=>strtotime($v['last_time_call_6month']),
                'msg_count_1month'=>$v['msg_count_1month'],
            );
            $addnum[] = $add;
        }
        M('risk_contact_detail','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['risk_contact_detail']);
        $add = array(
            'user_id'=>$user_id,
            'call_count_holiday_3month'=>$str['all_contact_stats']['call_count_holiday_3month'],
            'call_count_holiday_6month'=>$str['all_contact_stats']['call_count_holiday_6month'],
            'call_count_call_time_over10min_6month'=>$str['all_contact_stats']['call_count_call_time_over10min_6month'],
            'contact_count_active_3month'=>$str['all_contact_stats']['contact_count_active_3month'],
            'contact_count_active_6month'=>$str['all_contact_stats']['contact_count_active_6month'],
            'call_count_active_6month'=>$str['all_contact_stats']['call_count_active_6month'],
            'call_time_3month'=>$str['all_contact_stats']['call_time_3month'],
            'msg_count_3month'=>$str['all_contact_stats']['msg_count_3month'],
            'call_time_1month'=>$str['all_contact_stats']['call_time_1month'],
            'call_time_passive_6month'=>$str['all_contact_stats']['call_time_passive_6month'],
            'call_count_active_3month'=>$str['all_contact_stats']['call_count_active_3month'],
            'call_time_6month'=>$str['all_contact_stats']['call_time_6month'],
            'call_count_late_night_3month'=>$str['all_contact_stats']['call_count_late_night_3month'],
            'call_count_late_night_6month'=>$str['all_contact_stats']['call_count_late_night_6month'],
            'call_count_passive_6month'=>$str['all_contact_stats']['call_count_passive_6month'],
            'call_time_active_6month'=>$str['all_contact_stats']['call_time_active_6month'],
            'msg_count_6month'=>$str['all_contact_stats']['msg_count_6month'],
            'contact_count_passive_6month'=>$str['all_contact_stats']['contact_count_passive_6month'],
            'call_count_work_time_6month'=>$str['all_contact_stats']['call_count_work_time_6month'],
            'call_count_call_time_5min10min_6month'=>$str['all_contact_stats']['call_count_call_time_5min10min_6month'],
            'call_time_active_3month'=>$str['all_contact_stats']['call_time_active_3month'],
            'contact_count_passive_3month'=>$str['all_contact_stats']['contact_count_passive_3month'],
            'call_count_passive_3month'=>$str['all_contact_stats']['call_count_passive_3month'],
            'call_count_3month'=>$str['all_contact_stats']['call_count_3month'],
            'contact_count_1month'=>$str['all_contact_stats']['contact_count_1month'],
            'call_count_work_time_3month'=>$str['all_contact_stats']['call_count_work_time_3month'],
            'call_count_workday_3month'=>$str['all_contact_stats']['call_count_workday_3month'],
            'call_count_6month'=>$str['all_contact_stats']['call_count_6month'],
            'call_count_offwork_time_3month'=>$str['all_contact_stats']['call_count_offwork_time_3month'],
            'call_count_offwork_time_6month'=>$str['all_contact_stats']['call_count_offwork_time_6month'],
            'contact_count_mutual_3month'=>$str['all_contact_stats']['contact_count_mutual_3month'],
            'call_count_1month'=>$str['all_contact_stats']['call_count_1month'],
            'call_time_passive_3month'=>$str['all_contact_stats']['call_time_passive_3month'],
            'call_count_call_time_less1min_6month'=>$str['all_contact_stats']['call_count_call_time_less1min_6month'],
            'contact_count_3month'=>$str['all_contact_stats']['contact_count_3month'],
            'contact_count_call_count_over10_3month'=>$str['all_contact_stats']['contact_count_call_count_over10_3month'],
            'call_count_workday_6month'=>$str['all_contact_stats']['call_count_workday_6month'],
            'contact_count_call_count_over10_6month'=>$str['all_contact_stats']['contact_count_call_count_over10_6month'],
            'contact_count_6month'=>$str['all_contact_stats']['contact_count_6month'],
            'contact_count_mutual_6month'=>$str['all_contact_stats']['contact_count_mutual_6month'],
            'call_count_call_time_1min5min_6month'=>$str['all_contact_stats']['call_count_call_time_1min5min_6month'],
        );
        M('all_contact_stats','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['all_contact_stats']);
        foreach ($str['all_contact_detail'] as $k=>$v){
            $add=array(
                'user_id'=>$user_id,
                'call_count_holiday_3month'=>$v['call_count_holiday_3month'],
                'call_count_holiday_6month'=>$v['call_count_holiday_6month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'msg_count_3month'=>$v['msg_count_3month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'contact_type'=>$v['contact_type'],
                'call_count_late_night_3month'=>$v['call_count_late_night_3month'],
                'call_count_late_night_6month'=>$v['call_count_late_night_6month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'msg_count_6month'=>$v['msg_count_6month'],
                'call_count_work_time_6month'=>$v['call_count_work_time_6month'],
                'first_time_call_6month'=>strtotime($v['first_time_call_6month']),
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
                'call_count_3month'=>$v['call_count_3month'],
                'contact_name'=>$v['contact_name'],
                'contact_relation'=>$v['contact_relation'],
                'call_count_work_time_3month'=>$v['call_count_work_time_3month'],
                'call_count_workday_3month'=>$v['call_count_workday_3month'],
                'call_count_6month'=>$v['call_count_6month'],
                'call_count_offwork_time_3month'=>$v['call_count_offwork_time_3month'],
                'call_count_offwork_time_6month'=>$v['call_count_offwork_time_6month'],
                'contact_number'=>$v['contact_number'],
                'contact_area'=>$v['contact_area'],
                'call_count_1week'=>$v['call_count_1week'],
                'contact_seq_no'=>$v['contact_seq_no'],
                'is_whole_day_call_3month'=>$v['is_whole_day_call_3month'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'is_whole_day_call_6month'=>$v['is_whole_day_call_6month'],
                'call_count_workday_6month'=>$v['call_count_workday_6month'],
                'last_time_call_6month'=>strtotime($v['last_time_call_6month']),
                'msg_count_1month'=>$v['msg_count_1month'],
            );
            $addnum[]=$add;

        }
        M('all_contact_detail','',C('NTH'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['all_contact_detail']);
        $add = array(
            'user_id'=>$user_id,
            't_0'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_0'],
            't_1'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_1'],
            't_2'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_2'],
            't_3'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_3'],
            't_4'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_4'],
            't_5'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_5'],
            't_6'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_6'],
            't_7'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_7'],
            't_8'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_8'],
            't_9'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_9'],
            't_10'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_10'],
            't_11'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_11'],
        );
        M('call_duration_workday_6month','',C('DB2_ZX'))->add($add);
        $add = array(
            'user_id'=>$user_id,
            't_0'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_0'],
            't_1'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_1'],
            't_2'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_2'],
            't_3'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_3'],
            't_4'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_4'],
            't_5'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_5'],
            't_6'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_6'],
            't_7'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_7'],
            't_8'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_8'],
            't_9'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_9'],
            't_10'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_10'],
            't_11'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_11'],
        );
        M('call_duration_holiday_6month','',C('DB2_ZX'))->add($add);
        $add = array(
            'user_id'=>$user_id,
            't_0'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_0'],
            't_1'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_1'],
            't_2'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_2'],
            't_3'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_3'],
            't_4'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_4'],
            't_5'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_5'],
            't_6'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_6'],
            't_7'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_7'],
            't_8'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_8'],
            't_9'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_9'],
            't_10'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_10'],
            't_11'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_11'],
        );
        M('call_duration_holiday_3month','',C('DB2_ZX'))->add($add);
        $add = array(
            'user_id'=>$user_id,
            't_0'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_0'],
            't_1'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_1'],
            't_2'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_2'],
            't_3'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_3'],
            't_4'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_4'],
            't_5'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_5'],
            't_6'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_6'],
            't_7'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_7'],
            't_8'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_8'],
            't_9'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_9'],
            't_10'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_10'],
            't_11'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_11'],
        );
        M('call_duration_workday_3month','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['call_duration_stats_2hour']);
        foreach ($str['all_contact_stats_per_month'] as $k=>$v){
            $add=array(
                'user_id'=>$user_id,
                'call_count_active'=>$v['call_count_active'],
                'call_count_passive'=>$v['call_count_passive'],
                'contact_count'=>$v['contact_count'],
                'call_time'=>$v['call_time'],
                'call_count_call_time_1min5min'=>$v['call_count_call_time_1min5min'],
                'contact_count_call_count_over10'=>$v['contact_count_call_count_over10'],
                'contact_count_active'=>$v['contact_count_active'],
                'call_count_call_time_less1min'=>$v['call_count_call_time_less1min'],
                'call_count_call_time_over10min'=>$v['call_count_call_time_over10min'],
                'call_count_offwork_time'=>$v['call_count_offwork_time'],
                'call_count_work_time'=>$v['call_count_work_time'],
                'contact_count_mutual'=>$v['contact_count_mutual'],
                'month'=>strtotime($v['month']),
                'call_time_passive'=>$v['call_time_passive'],
                'call_count_late_night'=>$v['call_count_late_night'],
                'call_count'=>$v['call_count'],
                'call_count_call_time_5min10min'=>$v['call_count_call_time_5min10min'],
                'call_time_active'=>$v['call_time_active'],
                'contact_count_passive'=>$v['contact_count_passive'],
                'msg_count'=>$v['msg_count'],
            );
            $addnum[]=$add;
        }
        M('all_contact_stats_per_month','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['all_contact_stats_per_month']);
        foreach ($str['risk_contact_stats'] as $k=>$v){
            $add= array(
                'user_id'=>$user_id,
                'call_count_3month'=>$v['call_count_3month'],
                'risk_type'=>$v['risk_type'],
                'contact_count_1month'=>$v['contact_count_1month'],
                'call_count_6month'=>$v['call_count_6month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'msg_count_3month'=>$v['msg_count_3month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'msg_count_6month'=>$v['msg_count_6month'],
                'contact_count_3month'=>$v['contact_count_3month'],
                'contact_count_6month'=>$v['contact_count_6month'],
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
            );
            $addnum[]=$add;
        }
        M('risk_contact_stats','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['risk_contact_stats']);
        foreach ($str['finance_contact_detail'] as $k=>$v){
            $add = array(
                'user_id'=>$user_id,
                'call_count_holiday_3month'=>$v['call_count_holiday_3month'],
                'call_count_holiday_6month'=>$v['call_count_holiday_6month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'msg_count_3month'=>$v['msg_count_3month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'contact_type'=>$v['contact_type'],
                'call_count_late_night_3month'=>$v['call_count_late_night_3month'],
                'call_count_late_night_6month'=>$v['call_count_late_night_6month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'msg_count_6month'=>$v['msg_count_6month'],
                'call_count_work_time_6month'=>$v['call_count_work_time_6month'],
                'first_time_call_6month'=>strtotime($v['first_time_call_6month']),
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
                'call_count_3month'=>$v['call_count_3month'],
                'contact_name'=>$v['contact_name'],
                'contact_relation'=>$v['contact_relation'],
                'call_count_work_time_3month'=>$v['call_count_work_time_3month'],
                'call_count_workday_3month'=>$v['call_count_workday_3month'],
                'call_count_6month'=>$v['call_count_6month'],
                'call_count_offwork_time_3month'=>$v['call_count_offwork_time_3month'],
                'call_count_offwork_time_6month'=>$v['call_count_offwork_time_6month'],
                'contact_number'=>$v['contact_number'],
                'contact_area'=>$v['contact_area'],
                'call_count_1week'=>$v['call_count_1week'],
                'contact_seq_no'=>$v['contact_seq_no'],
                'is_whole_day_call_3month'=>$v['is_whole_day_call_3month'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'is_whole_day_call_6month'=>$v['is_whole_day_call_6month'],
                'call_count_workday_6month'=>$v['call_count_workday_6month'],
                'last_time_call_6month'=>strtotime($v['last_time_call_6month']),
                'msg_count_1month'=>$v['msg_count_1month'],
            );
            $addnum[]=$add;
        }
        M('finance_contact_detail','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['finance_contact_detail']);
        foreach ($str['call_area_stats_per_city'] as $k=>$v){
            $add= array(
                'user_id'=>$user_id,
                'call_count_holiday_3month'=>$v['call_count_holiday_3month'],
                'call_count_holiday_6month'=>$v['call_count_holiday_6month'],
                'active_day_1call_6month'=>$v['active_day_1call_6month'],
                'active_day_1call_3month'=>$v['active_day_1call_3month'],
                'active_day_1call_active_3month'=>$v['active_day_1call_active_3month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'max_continue_active_day_1call_1month'=>$v['max_continue_active_day_1call_1month'],
                'active_day_1call_active_6month'=>$v['active_day_1call_active_6month'],
                'continue_active_day_over3_1call_6month'=>$v['continue_active_day_over3_1call_6month'],
                'call_area_seq_no'=>$v['call_area_seq_no'],
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
                'call_count_3month'=>$v['call_count_3month'],
                'call_count_workday_3month'=>$v['call_count_workday_3month'],
                'call_count_6month'=>$v['call_count_6month'],
                'continue_active_day_over3_1call_3month'=>$v['continue_active_day_over3_1call_3month'],
                'continue_active_day_over1_1call_6month'=>$v['continue_active_day_over1_1call_6month'],
                'max_continue_active_day_1call_3month'=>$v['max_continue_active_day_1call_3month'],
                'max_continue_active_day_1call_6month'=>$v['max_continue_active_day_1call_6month'],
                'continue_active_day_over1_1call_3month'=>$v['continue_active_day_over1_1call_3month'],
                'call_area_city'=>$v['call_area_city'],
                'active_day_1call_1month'=>$v['active_day_1call_1month'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'continue_active_day_over3_1call_1month'=>$v['continue_active_day_over3_1call_1month'],
                'call_count_workday_6month'=>$v['call_count_workday_6month'],
                'continue_active_day_over1_1call_1month'=>$v['continue_active_day_over1_1call_1month'],
                'active_day_1call_active_1month'=>$v['active_day_1call_active_1month'],
            );
            $addnum[]=$add;
        }
        M('call_area_stats_per_city','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['call_area_stats_per_city']);
        $this->return=['ret'=>'1001','code'=>'success'];
//        var_dump($str);
    }
    public function get_data1()
    {
        $user_id = '367';
        $task_id = M('tdyyshd_report', '', C('DB2_ZX'))->where(array('user_id' => $user_id))->getField('task_id');
        $task_id = 'TASKYYS100000201810121522210711032813';
        if (empty($task_id)) {
            $this->return = ['ret' => '1002', 'code' => '该用户还未有task_id'];
            exit;
        }
        $post_data['task_id'] = $task_id;
        $url = 'https://api.shujumohe.com/octopus/report.task.query/v2?partner_code=sharedcash&partner_key=dfc99c9bad014db59fc7ed6d4187ae49';
        $result = $this->post2($url, $post_data);
        $result = json_decode($result, true);
        $str = base64_decode($result['data']);
        $str = gzdecode($str);
        $str = json_decode($str, true);
//        var_dump($str);die;
        $add_app['call_count_late_night_3month'] = empty($str['all_contact_stats']['call_count_late_night_3month'])?'0':$str['all_contact_stats']['call_count_late_night_3month'];
        $add_app['contact_count_mutual_3month'] = empty($str['all_contact_stats']['contact_count_mutual_3month'])?'0':$str['all_contact_stats']['contact_count_mutual_3month'];
        $add_app['call_count_call_time_less1min_6month'] = empty($str['all_contact_stats']['call_count_call_time_less1min_6month'])?'0':$str['all_contact_stats']['call_count_call_time_less1min_6month'];
        $add_app['call_count_6month'] = empty($str['all_contact_stats']['call_count_6month'])?'0':$str['all_contact_stats']['call_count_6month'];
        $add_app['contact_count_call_count_over10_6month'] = empty($str['all_contact_stats']['contact_count_call_count_over10_6month'])?'0':$str['all_contact_stats']['contact_count_call_count_over10_6month'];
        $add_app['call_count_call_time_over10min_6month'] = empty($str['all_contact_stats']['call_count_call_time_over10min_6month'])?'0':$str['all_contact_stats']['call_count_call_time_over10min_6month'];
        $add_app['call_count_active'] = empty($str['all_contact_stats_per_month']['call_count_active'])?'0':$str['all_contact_stats_per_month']['call_count_active'];
        $add_app['contact_count_active'] = empty($str['all_contact_stats_per_month']['contact_count_active'])?'0':$str['all_contact_stats_per_month']['contact_count_active'];
        $add_app['call_count_late_night'] = empty($str['all_contact_stats_per_month']['call_count_late_night'])?'0':$str['all_contact_stats_per_month']['call_count_late_night'];
        $add_app['call_count'] = empty($str['all_contact_stats_per_month']['call_count'])?'0':$str['all_contact_stats_per_month']['call_count'];
        $add_app['sex'] = $str['user_info']['gender'];
        $add_app['age'] = $str['user_info']['age'];
        $add_app['ctime'] = M('user', '', C('DB2'))->where(array('id' => $user_id))->getField('ctime');
        $add_app['td_7days'] = M('get_td_data', '', C('DB2_ZX'))->where(array('user_id' => $user_id))->getField('seven_day');
        $add_app['mobile_net_age'] = $str['mobile_info']['mobile_net_age'];
        $add_app['consume_amount_3month'] = $str['carrier_consumption_stats']['consume_amount_3month'];
        $a = json_encode($add_app,JSON_UNESCAPED_UNICODE);
        M('user_applycard', '', C('DB2'))->add($add_app);
        $url = 'https://jallzf.miaodaoxj.com:444/xycsf/getApplyCard';
        $res = $this->getcurl($url,$a,array('Content-type: application/json','charset:utf-8'));
        file_put_contents('./sqpfk.txt', 'user_id:' . $user_id . '结果:' . $res, FILE_APPEND);
        var_dump($res);die;
    }
    public function get_data11()
    {
        $user_id = '367';
        $task_id = M('tdyyshd_report', '', C('DB2_ZX'))->where(array('user_id' => $user_id))->getField('task_id');
        $task_id = 'TASKYYS100000201810121522210711032813';
        if (empty($task_id)) {
            $this->return = ['ret' => '1002', 'code' => '该用户还未有task_id'];
            exit;
        }
        $post_data['task_id'] = $task_id;
        $url = 'https://api.shujumohe.com/octopus/report.task.query/v2?partner_code=sharedcash&partner_key=dfc99c9bad014db59fc7ed6d4187ae49';
        $result = $this->post2($url, $post_data);
        $result = json_decode($result, true);
        $str = base64_decode($result['data']);
        $str = gzdecode($str);
        $str = json_decode($str, true);
//        var_dump($str);die;
        $add_app['call_count_late_night_3month'] = empty($str['all_contact_stats']['call_count_late_night_3month'])?'0':$str['all_contact_stats']['call_count_late_night_3month'];
        $add_app['contact_count_mutual_3month'] = empty($str['all_contact_stats']['contact_count_mutual_3month'])?'0':$str['all_contact_stats']['contact_count_mutual_3month'];
        $add_app['call_count_call_time_less1min_6month'] = empty($str['all_contact_stats']['call_count_call_time_less1min_6month'])?'0':$str['all_contact_stats']['call_count_call_time_less1min_6month'];
        $add_app['call_count_6month'] = empty($str['all_contact_stats']['call_count_6month'])?'0':$str['all_contact_stats']['call_count_6month'];
        $add_app['contact_count_call_count_over10_6month'] = empty($str['all_contact_stats']['contact_count_call_count_over10_6month'])?'0':$str['all_contact_stats']['contact_count_call_count_over10_6month'];
        $add_app['call_count_call_time_over10min_6month'] = empty($str['all_contact_stats']['call_count_call_time_over10min_6month'])?'0':$str['all_contact_stats']['call_count_call_time_over10min_6month'];
        $add_app['call_count_active'] = empty($str['all_contact_stats_per_month']['call_count_active'])?'0':$str['all_contact_stats_per_month']['call_count_active'];
        $add_app['contact_count_active'] = empty($str['all_contact_stats_per_month']['contact_count_active'])?'0':$str['all_contact_stats_per_month']['contact_count_active'];
        $add_app['call_count_late_night'] = empty($str['all_contact_stats_per_month']['call_count_late_night'])?'0':$str['all_contact_stats_per_month']['call_count_late_night'];
        $add_app['call_count'] = empty($str['all_contact_stats_per_month']['call_count'])?'0':$str['all_contact_stats_per_month']['call_count'];
        $add_app['sex'] = $str['user_info']['gender'];
        $add_app['age'] = $str['user_info']['age'];
        $add_app['ctime'] = M('user', '', C('DB2'))->where(array('id' => $user_id))->getField('ctime');
        $add_app['td_7days'] = M('get_td_data', '', C('DB2_ZX'))->where(array('user_id' => $user_id))->getField('seven_day');
        $add_app['mobile_net_age'] = $str['mobile_info']['mobile_net_age'];
        $add_app['consume_amount_3month'] = $str['carrier_consumption_stats']['consume_amount_3month'];
        $a = json_encode($add_app,JSON_UNESCAPED_UNICODE);
        M('user_applycard', '', C('DB2'))->add($add_app);
        $url = 'https://jallzf.miaodaoxj.com:444/xycsf/getApplyCard';
        $res = $this->getcurl($url,$a,array('Content-type: application/json','charset:utf-8'));
        file_put_contents('./sqpfk.txt', 'user_id:' . $user_id . '结果:' . $res, FILE_APPEND);
        var_dump($res);die;
    }
    public function get_data1_test()
    {
        $a = M('test','',C('DB2_ZX'))->where(['status'=>'2'])->field('task_id,mobile')->limit(1)->select();
        if (empty($a)) {
            $this->return = ['ret' => '1002', 'code' => '无用户'];
            exit;
        }
        foreach ($a as $k=>$v){
            $has = M('contact_suspect_collection_analysis','',C('DB2_ZX'))->where(['mobile'=>$v['mobile']])->getField('id');
            if(empty($has)){
                $post_data['task_id'] = $v['task_id'];
                $url = 'https://api.shujumohe.com/octopus/report.task.query/v2?partner_code=sharedcash&partner_key=dfc99c9bad014db59fc7ed6d4187ae49';
                $result = $this->post2($url, $post_data);
                $result = json_decode($result, true);
                $str = base64_decode($result['data']);
                $str = gzdecode($str);
                $str = json_decode($str, true);
                foreach ($str['contact_suspect_collection_analysis'] as $b=>$c){
                    $add = array(
                        'mobile'=>$v['mobile'],
                        'call_count_passive_1month'=>$c['call_count_passive_1month'],
                        'call_time_active_1month'=>$c['call_time_active_1month'],
                        'contact_count_active_3month'=>$c['contact_count_active_3month'],
                        'contact_count_active_6month'=>$c['contact_count_active_6month'],
                        'call_count_active_6month'=>$c['call_count_active_6month'],
                        'call_time_3month'=>$c['call_time_3month'],
                        'msg_count_3month'=>$c['msg_count_3month'],
                        'call_time_1month'=>$c['call_time_1month'],
                        'call_time_passive_6month'=>$c['call_time_passive_6month'],
                        'call_count_active_3month'=>$c['call_count_active_3month'],
                        'call_time_6month'=>$c['call_time_6month'],
                        'call_count_passive_6month'=>$c['call_count_passive_6month'],
                        'call_time_active_6month'=>$c['call_time_active_6month'],
                        'msg_count_6month'=>$c['msg_count_6month'],
                        'contact_count_passive_6month'=>$c['contact_count_passive_6month'],
                        'call_time_active_3month'=>$c['call_time_active_3month'],
                        'call_count_passive_3month'=>$c['call_count_passive_3month'],
                        'contact_count_passive_3month'=>$c['contact_count_passive_3month'],
                        'call_count_3month'=>$c['call_count_3month'],
                        'risk_type'=>$c['risk_type'],
                        'contact_count_1month'=>$c['contact_count_1month'],
                        'call_count_6month'=>$c['call_count_6month'],
                        'call_count_active_1month'=>$c['call_count_active_1month'],
                        'contact_count_active_1month'=>$c['contact_count_active_1month'],
                        'call_time_passive_1month'=>$c['call_time_passive_1month'],
                        'call_count_1month'=>$c['call_count_1month'],
                        'call_time_passive_3month'=>$c['call_time_passive_3month'],
                        'contact_count_passive_1month'=>$c['contact_count_passive_1month'],
                        'contact_count_3month'=>$c['contact_count_3month'],
                        'contact_count_6month'=>$c['contact_count_6month'],
                        'msg_count_1month'=>$c['msg_count_1month'],
                        'ctime'=>time(),
                    );
                    $addnum[$k] = $add;
                }
                M('contact_suspect_collection_analysis','',C('DB2_ZX'))->addALL($addnum);
                $addnum = [];

            }else{
                echo json_encode($has);
            }
            M('test','',C('DB2_ZX'))->where(['mobile'=>$v['mobile']])->setField('status','3');
        }
    }
    public function getcurl($url = '',$data='',$header='')
    {
        $ch = curl_init();
        if (!empty($header)) {
//            $header=array('Content-type: application/json','charset:utf-8'); 示例
            curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        }
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, '1');
        curl_setopt($ch, CURLOPT_URL, $url);
        if (!empty($data)) {
            curl_setopt($ch, CURLOPT_POST, '1');
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        }
        //禁用后cURL将终止从服务端进行验证
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $res = curl_exec($ch);
        if (curl_error($ch)) {
            return '错误信息:' . curl_error($ch);
        }
        curl_close($ch);
        return $res;

    }
    public function get_data(){
        $user_id = I('user_id');
        $task_id =M('tdyyshd_report','',C('DB2_ZX'))->where(array('user_id'=>$user_id))->getField('task_id');
        if(empty($task_id)){
            $this->return = ['ret' => '1002','code'=>'该用户还未有task_id'];
            exit;
        }
        $contact_data = M('user_contact','',C('DB2'))->where(Array('user_id'=>$user_id))->field('relative_mobile,other_mobile')->find();
        $post_data['task_id'] =$task_id;
        $post_data['contact1_mobile'] =$contact_data['relative_mobile'];
        $post_data['contact2_mobile'] =$contact_data['other_mobile'];
        $mobile = M('user','',C('DB2'))->where(['id'=>$user_id])->getField('mobile');
        $url = 'https://api.shujumohe.com/octopus/report.task.query/v2?partner_code=sharedcash&partner_key=dfc99c9bad014db59fc7ed6d4187ae49';
        $result = $this->post2($url,$post_data);
        $result = json_decode($result,true);
        $str = base64_decode($result['data']);
        $str = gzdecode($str);
        $str = json_decode($str,true);
        $add_app['call_count_late_night_3month'] = empty($str['all_contact_stats']['call_count_late_night_3month'])?'0':$str['all_contact_stats']['call_count_late_night_3month'];
        $add_app['contact_count_mutual_3month'] = empty($str['all_contact_stats']['contact_count_mutual_3month'])?'0':$str['all_contact_stats']['contact_count_mutual_3month'];
        $add_app['call_count_call_time_less1min_6month'] = empty($str['all_contact_stats']['call_count_call_time_less1min_6month'])?'0':$str['all_contact_stats']['call_count_call_time_less1min_6month'];
        $add_app['call_count_6month'] = empty($str['all_contact_stats']['call_count_6month'])?'0':$str['all_contact_stats']['call_count_6month'];
        $add_app['contact_count_call_count_over10_6month'] = empty($str['all_contact_stats']['contact_count_call_count_over10_6month'])?'0':$str['all_contact_stats']['contact_count_call_count_over10_6month'];
        $add_app['call_count_call_time_over10min_6month'] = empty($str['all_contact_stats']['call_count_call_time_over10min_6month'])?'0':$str['all_contact_stats']['call_count_call_time_over10min_6month'];
        $add_app['call_count_active'] = empty($str['all_contact_stats_per_month']['call_count_active'])?'0':$str['all_contact_stats_per_month']['call_count_active'];
        $add_app['contact_count_active'] = empty($str['all_contact_stats_per_month']['contact_count_active'])?'0':$str['all_contact_stats_per_month']['contact_count_active'];
        $add_app['call_count_late_night'] = empty($str['all_contact_stats_per_month']['call_count_late_night'])?'0':$str['all_contact_stats_per_month']['call_count_late_night'];
        $add_app['call_count'] = empty($str['all_contact_stats_per_month']['call_count'])?'0':$str['all_contact_stats_per_month']['call_count'];
        $add_app['sex'] = $str['user_info']['gender'];
        $add_app['age'] = $str['user_info']['age'];
        $add_app['ctime'] = M('user', '', C('DB2'))->where(array('id' => $user_id))->getField('ctime');
        $add_app['td_7days'] = M('get_td_data', '', C('DB2_ZX'))->where(array('user_id' => $user_id))->getField('seven_day');
        $add_app['mobile_net_age'] = empty($str['mobile_info']['mobile_net_age'])?'0':$str['mobile_info']['mobile_net_age'];
        $add_app['consume_amount_3month'] = empty($str['carrier_consumption_stats']['consume_amount_3month'])?'0':$str['carrier_consumption_stats']['consume_amount_3month'];
//        $a = json_encode($add_app,JSON_UNESCAPED_UNICODE);
        M('user_applycard', '', C('DB2'))->add($add_app);
//        $url = 'https://jallzf.miaodaoxj.com:444/xycsf/getApplyCard';
//        $res = $this->getcurl($url,$a,array('Content-type: application/json','charset:utf-8'));
//        $res = json_decode($res,true);
//        M('user','',C('DB2'))->save(array('apply_score'=>$res['data']['score'],'apply_grade'=>$res['data']['grade']));
        foreach ($str['travel_track_analysis_per_city'] as $k=>$v){
            $add = array(
                'mobile'=>$mobile,
                'arrive_city'=>$v['arrive_city'],
                'arrive_day_type'=>$v['arrive_day_type'],
                'leave_city'=>$v['leave_city'],
                'leave_day_type'=>$v['leave_day_type'],
                'arrive_day'=>strtotime($v['arrive_day']),
                'leave_day'=>strtotime($v['leave_day']),
            );
            $addnum[] = $add;
        }
        $has_travel_track_analysis_per_city = M('travel_track_analysis_per_city','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_travel_track_analysis_per_city){
            M('travel_track_analysis_per_city','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('travel_track_analysis_per_city','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['travel_track_analysis_per_city']);
        foreach ($str['contact_area_stats_per_city'] as $k=>$v){
            $add = array(
                'mobile'=>$mobile,
                'call_count_holiday_3month'=>$v['call_count_holiday_3month'],
                'call_count_holiday_6month'=>$v['call_count_holiday_6month'],
                'contact_count_active_3month'=>$v['contact_count_active_3month'],
                'contact_count_active_6month'=>$v['contact_count_active_6month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'msg_count_3month'=>$v['msg_count_3month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'call_count_late_night_3month'=>$v['call_count_late_night_3month'],
                'contact_area_city'=>$v['contact_area_city'],
                'call_count_late_night_6month'=>$v['call_count_late_night_6month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'msg_count_6month'=>$v['msg_count_6month'],
                'contact_count_passive_6month'=>$v['contact_count_passive_6month'],
                'call_count_work_time_6month'=>$v['call_count_work_time_6month'],
                'call_count_call_time_5min10min_6month'=>$v['call_count_call_time_5min10min_6month'],
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'contact_count_passive_3month'=>$v['contact_count_passive_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
                'call_count_3month'=>$v['call_count_3month'],
                'contact_count_1month'=>$v['contact_count_1month'],
                'call_count_work_time_3month'=>$v['call_count_work_time_3month'],
                'call_count_workday_3month'=>$v['call_count_workday_3month'],
                'call_count_6month'=>$v['call_count_6month'],
                'call_count_offwork_time_3month'=>$v['call_count_offwork_time_3month'],
                'call_count_offwork_time_6month'=>$v['call_count_offwork_time_6month'],
                'contact_count_mutual_3month'=>$v['contact_count_mutual_3month'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'call_count_call_time_less1min_6month'=>$v['call_count_call_time_less1min_6month'],
                'contact_count_3month'=>$v['contact_count_3month'],
                'contact_count_call_count_over10_3month'=>$v['contact_count_call_count_over10_3month'],
                'contact_area_seq_no'=>$v['contact_area_seq_no'],
                'call_count_workday_6month'=>$v['call_count_workday_6month'],
                'contact_count_call_count_over10_6month'=>$v['contact_count_call_count_over10_6month'],
                'contact_count_6month'=>$v['contact_count_6month'],
                'contact_count_mutual_6month'=>$v['contact_count_mutual_6month'],
                'call_count_call_time_1min5min_6month'=>$v['call_count_call_time_1min5min_6month'],
            );
            $addnum[]=$add;
        }
        $has_contact_area_stats_per_city =M('contact_area_stats_per_city','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_contact_area_stats_per_city){
            M('contact_area_stats_per_city','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('contact_area_stats_per_city','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['contact_area_stats_per_city']);
        $add = [
            'mobile'=>$mobile,
            'active_day_1call_3month'=>$str['active_silence_stats']['active_day_1call_3month'],
            'active_day_1call_6month'=>$str['active_silence_stats']['active_day_1call_6month'],
            'max_continue_active_day_1call_3month'=>$str['active_silence_stats']['max_continue_active_day_1call_3month'],
            'max_continue_active_day_1call_6month'=>$str['active_silence_stats']['max_continue_active_day_1call_6month'],
            'silence_day_0call_3month'=>$str['active_silence_stats']['silence_day_0call_3month'],
            'silence_day_0call_active_3month'=>$str['active_silence_stats']['silence_day_0call_active_3month'],
            'silence_day_0call_0msg_send_3month'=>$str['active_silence_stats']['silence_day_0call_0msg_send_3month'],
            'silence_day_0call_6month'=>$str['active_silence_stats']['silence_day_0call_6month'],
            'silence_day_0call_active_6month'=>$str['active_silence_stats']['silence_day_0call_active_6month'],
            'silence_day_0call_0msg_send_6month'=>$str['active_silence_stats']['silence_day_0call_0msg_send_6month'],
            'continue_silence_day_over3_0call_3month'=>$str['active_silence_stats']['continue_silence_day_over3_0call_3month'],
            'continue_silence_day_over15_0call_3month'=>$str['active_silence_stats']['continue_silence_day_over15_0call_3month'],
            'continue_silence_day_over3_0call_active_3month'=>$str['active_silence_stats']['continue_silence_day_over3_0call_active_3month'],
            'continue_silence_day_over15_0call_active_3month'=>$str['active_silence_stats']['continue_silence_day_over15_0call_active_3month'],
            'continue_silence_day_over3_0call_0msg_send_3month'=>$str['active_silence_stats']['continue_silence_day_over3_0call_0msg_send_3month'],
            'continue_silence_day_over15_0call_0msg_send_3month'=>$str['active_silence_stats']['continue_silence_day_over15_0call_0msg_send_3month'],
            'continue_silence_day_over3_0call_6month'=>$str['active_silence_stats']['continue_silence_day_over3_0call_6month'],
            'continue_silence_day_over15_0call_6month'=>$str['active_silence_stats']['continue_silence_day_over15_0call_6month'],
            'continue_silence_day_over3_0call_active_6month'=>$str['active_silence_stats']['continue_silence_day_over3_0call_active_6month'],
            'continue_silence_day_over15_0call_active_6month'=>$str['active_silence_stats']['continue_silence_day_over15_0call_active_6month'],
            'continue_silence_day_over3_0call_0msg_send_6month'=>$str['active_silence_stats']['continue_silence_day_over3_0call_0msg_send_6month'],
            'continue_silence_day_over15_0call_0msg_send_6month'=>$str['active_silence_stats']['continue_silence_day_over15_0call_0msg_send_6month'],
            'max_continue_silence_day_0call_3month'=>$str['active_silence_stats']['max_continue_silence_day_0call_3month'],
            'max_continue_silence_day_0call_active_3month'=>$str['active_silence_stats']['max_continue_silence_day_0call_active_3month'],
            'max_continue_silence_day_0call_0msg_send_3month'=>$str['active_silence_stats']['max_continue_silence_day_0call_0msg_send_3month'],
            'max_continue_silence_day_0call_6month'=>$str['active_silence_stats']['max_continue_silence_day_0call_6month'],
            'max_continue_silence_day_0call_active_6month'=>$str['active_silence_stats']['max_continue_silence_day_0call_active_6month'],
            'max_continue_silence_day_0call_0msg_send_6month'=>$str['active_silence_stats']['max_continue_silence_day_0call_0msg_send_6month'],
            'gap_day_last_silence_day_0call_6month'=>$str['active_silence_stats']['gap_day_last_silence_day_0call_6month'],
            'gap_day_last_silence_day_0call_active_6month'=>$str['active_silence_stats']['gap_day_last_silence_day_0call_active_6month'],
            'gap_day_last_silence_day_0call_0msg_send_6month'=>$str['active_silence_stats']['gap_day_last_silence_day_0call_0msg_send_6month'],
            'ctime'=>time(),
        ];
        M('active_silence_stats','',C('DB2_ZX'))->add($add);
        unset($add);
        foreach ($str['active_silence_stats']['continue_silence_day_over3_0call_3month_detail'] as $b=>$c){
            $addnum[$b] =[
                'mobile'=>$mobile,
                'start_date'=>strtotime($c['start_date']),
                'end_date'=>strtotime($c['end_date']),
                'ctime'=>time(),
                'type'=>'1',
            ];
        }
        M('active_silence_stats_detail','',C('DB2_ZX'))->addALL($addnum);
        $addnum = [];
        foreach ($str['active_silence_stats']['continue_silence_day_over15_0call_3month_detail'] as $b=>$c){
            $addnum[$b] =[
                'mobile'=>$mobile,
                'start_date'=>strtotime($c['start_date']),
                'end_date'=>strtotime($c['end_date']),
                'ctime'=>time(),
                'type'=>'2',
            ];
        }
        M('active_silence_stats_detail','',C('DB2_ZX'))->addALL($addnum);
        $addnum = [];
        foreach ($str['active_silence_stats']['continue_silence_day_over3_0call_active_3month_detail'] as $b=>$c){
            $addnum[$b] =[
                'mobile'=>$mobile,
                'start_date'=>strtotime($c['start_date']),
                'end_date'=>strtotime($c['end_date']),
                'ctime'=>time(),
                'type'=>'3',
            ];
        }
        M('active_silence_stats_detail','',C('DB2_ZX'))->addALL($addnum);
        $addnum = [];
        foreach ($str['active_silence_stats']['continue_silence_day_over15_0call_active_3month_detail'] as $b=>$c){
            $addnum[$b] =[
                'mobile'=>$mobile,
                'start_date'=>strtotime($c['start_date']),
                'end_date'=>strtotime($c['end_date']),
                'ctime'=>time(),
                'type'=>'4',
            ];
        }
        M('active_silence_stats_detail','',C('DB2_ZX'))->addALL($addnum);
        $addnum = [];
        foreach ($str['active_silence_stats']['continue_silence_day_over3_0call_0msg_send_3month_detail'] as $b=>$c){
            $addnum[$b] =[
                'mobile'=>$mobile,
                'start_date'=>strtotime($c['start_date']),
                'end_date'=>strtotime($c['end_date']),
                'ctime'=>time(),
                'type'=>'5',
            ];
        }
        M('active_silence_stats_detail','',C('DB2_ZX'))->addALL($addnum);
        $addnum = [];
        foreach ($str['active_silence_stats']['continue_silence_day_over15_0call_0msg_send_3month_detail'] as $b=>$c){
            $addnum[$b] =[
                'mobile'=>$mobile,
                'start_date'=>strtotime($c['start_date']),
                'end_date'=>strtotime($c['end_date']),
                'ctime'=>time(),
                'type'=>'6',
            ];
        }
        M('active_silence_stats_detail','',C('DB2_ZX'))->addALL($addnum);
        $addnum = [];
        foreach ($str['active_silence_stats']['continue_silence_day_over3_0call_6month_detail'] as $b=>$c){
            $addnum[$b] =[
                'mobile'=>$mobile,
                'start_date'=>strtotime($c['start_date']),
                'end_date'=>strtotime($c['end_date']),
                'ctime'=>time(),
                'type'=>'7',
            ];
        }
        M('active_silence_stats_detail','',C('DB2_ZX'))->addALL($addnum);
        $addnum = [];
        foreach ($str['active_silence_stats']['continue_silence_day_over15_0call_6month_detail'] as $b=>$c){
            $addnum[$b] =[
                'mobile'=>$mobile,
                'start_date'=>strtotime($c['start_date']),
                'end_date'=>strtotime($c['end_date']),
                'ctime'=>time(),
                'type'=>'8',
            ];
        }
        M('active_silence_stats_detail','',C('DB2_ZX'))->addALL($addnum);
        $addnum = [];
        foreach ($str['active_silence_stats']['continue_silence_day_over3_0call_active_6month_detail'] as $b=>$c){
            $addnum[$b] =[
                'mobile'=>$mobile,
                'start_date'=>strtotime($c['start_date']),
                'end_date'=>strtotime($c['end_date']),
                'ctime'=>time(),
                'type'=>'9',
            ];
        }
        M('active_silence_stats_detail','',C('DB2_ZX'))->addALL($addnum);
        $addnum = [];
        foreach ($str['active_silence_stats']['continue_silence_day_over15_0call_active_6month_detail'] as $b=>$c){
            $addnum[$b] =[
                'mobile'=>$mobile,
                'start_date'=>strtotime($c['start_date']),
                'end_date'=>strtotime($c['end_date']),
                'ctime'=>time(),
                'type'=>'10',
            ];
        }
        M('active_silence_stats_detail','',C('DB2_ZX'))->addALL($addnum);
        $addnum = [];
        foreach ($str['active_silence_stats']['continue_silence_day_over3_0call_0msg_send_6month_detail'] as $b=>$c){
            $addnum[$b] =[
                'mobile'=>$mobile,
                'start_date'=>strtotime($c['start_date']),
                'end_date'=>strtotime($c['end_date']),
                'ctime'=>time(),
                'type'=>'11',
            ];
        }
        M('active_silence_stats_detail','',C('DB2_ZX'))->addALL($addnum);
        $addnum = [];
        foreach ($str['active_silence_stats']['continue_silence_day_over15_0call_0msg_send_6month_detail'] as $b=>$c){
            $addnum[$b] =[
                'mobile'=>$mobile,
                'start_date'=>strtotime($c['start_date']),
                'end_date'=>strtotime($c['end_date']),
                'ctime'=>time(),
                'type'=>'12',
            ];
        }
        M('active_silence_stats_detail','',C('DB2_ZX'))->addALL($addnum);
        $addnum = [];
        $add  =array(
            'mobile'=>$mobile,
            'recharge_amount_3month'=>$str['carrier_consumption_stats']['recharge_amount_3month'],
            'consume_amount_1month'=>$str['carrier_consumption_stats']['consume_amount_1month'],
            'recharge_count_1month'=>$str['carrier_consumption_stats']['recharge_count_1month'],
            'recharge_amount_6month'=>$str['carrier_consumption_stats']['recharge_amount_6month'],
            'consume_amount_6month'=>$str['carrier_consumption_stats']['consume_amount_6month'],
            'recharge_count_3month'=>$str['carrier_consumption_stats']['recharge_count_3month'],
            'recharge_amount_1month'=>$str['carrier_consumption_stats']['recharge_amount_1month'],
            'consume_amount_3month'=>$str['carrier_consumption_stats']['consume_amount_3month'],
            'recharge_count_6month'=>$str['carrier_consumption_stats']['recharge_count_6month'],
        );
        $has_carrier_consumption_stats =M('carrier_consumption_stats','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_carrier_consumption_stats){
            M('carrier_consumption_stats','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('carrier_consumption_stats','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['carrier_consumption_stats']);
        $add = array(
            'mobile'=>$mobile,
            'call_count_holiday_3month'=>$str['emergency_contact1_detail']['call_count_holiday_3month'],
            'call_count_holiday_6month'=>$str['emergency_contact1_detail']['call_count_holiday_6month'],
            'call_count_active_6month'=>$str['emergency_contact1_detail']['call_count_active_6month'],
            'call_time_3month'=>$str['emergency_contact1_detail']['call_time_3month'],
            'msg_count_3month'=>$str['emergency_contact1_detail']['msg_count_3month'],
            'call_time_passive_6month'=>$str['emergency_contact1_detail']['call_time_passive_6month'],
            'call_time_1month'=>$str['emergency_contact1_detail']['call_time_1month'],
            'call_count_active_3month'=>$str['emergency_contact1_detail']['call_count_active_3month'],
            'call_time_6month'=>$str['emergency_contact1_detail']['call_time_6month'],
            'contact_type'=>$str['emergency_contact1_detail']['contact_type'],
            'call_count_late_night_3month'=>$str['emergency_contact1_detail']['call_count_late_night_3month'],
            'call_count_late_night_6month'=>$str['emergency_contact1_detail']['call_count_late_night_6month'],
            'call_count_passive_6month'=>$str['emergency_contact1_detail']['call_count_passive_6month'],
            'call_time_active_6month'=>$str['emergency_contact1_detail']['call_time_active_6month'],
            'msg_count_6month'=>$str['emergency_contact1_detail']['msg_count_6month'],
            'call_count_work_time_6month'=>$str['emergency_contact1_detail']['call_count_work_time_6month'],
            'first_time_call_6month'=>strtotime($str['emergency_contact1_detail']['first_time_call_6month']),
            'call_time_active_3month'=>$str['emergency_contact1_detail']['call_time_active_3month'],
            'call_count_passive_3month'=>$str['emergency_contact1_detail']['call_count_passive_3month'],
            'call_count_3month'=>$str['emergency_contact1_detail']['call_count_3month'],
            'contact_name'=>$str['emergency_contact1_detail']['contact_name'],
            'contact_relation'=>$str['emergency_contact1_detail']['contact_relation'],
            'call_count_work_time_3month'=>$str['emergency_contact1_detail']['call_count_work_time_3month'],
            'call_count_workday_3month'=>$str['emergency_contact1_detail']['call_count_workday_3month'],
            'call_count_6month'=>$str['emergency_contact1_detail']['call_count_6month'],
            'call_count_offwork_time_3month'=>$str['emergency_contact1_detail']['call_count_offwork_time_3month'],
            'call_count_offwork_time_6month'=>$str['emergency_contact1_detail']['call_count_offwork_time_6month'],
            'contact_number'=>$str['emergency_contact1_detail']['contact_number'],
            'contact_area'=>$str['emergency_contact1_detail']['contact_area'],
            'call_count_1week'=>$str['emergency_contact1_detail']['call_count_1week'],
            'contact_seq_no'=>$str['emergency_contact1_detail']['contact_seq_no'],
            'is_whole_day_call_3month'=>$str['emergency_contact1_detail']['is_whole_day_call_3month'],
            'call_count_1month'=>$str['emergency_contact1_detail']['call_count_1month'],
            'call_time_passive_3month'=>$str['emergency_contact1_detail']['call_time_passive_3month'],
            'is_whole_day_call_6month'=>$str['emergency_contact1_detail']['is_whole_day_call_6month'],
            'call_count_workday_6month'=>$str['emergency_contact1_detail']['call_count_workday_6month'],
            'last_time_call_6month'=>strtotime($str['emergency_contact1_detail']['last_time_call_6month']),
            'msg_count_1month'=>$str['emergency_contact1_detail']['msg_count_1month'],
        );
        $has_emergency_contact1_detail = M('emergency_contact1_detail','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_emergency_contact1_detail){
            M('emergency_contact1_detail','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('emergency_contact1_detail','',C('DB2_ZX'))->add($add);

        unset($add);
        unset($str['emergency_contact1_detail']);
        $add = array(
            'mobile'=>$mobile,
            'is_top10_contact_in_blacklist'=>$str['info_check']['is_top10_contact_in_blacklist'],
            'is_contact4_called_6month'=>$str['info_check']['is_contact4_called_6month'],
            'is_net_addr_call_addr_3month'=>$str['info_check']['is_net_addr_call_addr_3month'],
            'is_top10_contact_in_manyheads_1month'=>$str['info_check']['is_top10_contact_in_manyheads_1month'],
            'is_identity_code_reliable'=>$str['info_check']['is_identity_code_reliable'],
            'is_contact2_called_6month'=>$str['info_check']['is_contact2_called_6month'],
            'is_work_tel_called_6month'=>$str['info_check']['is_work_tel_called_6month'],
            'is_top10_contact_in_manyheads_6month'=>$str['info_check']['is_top10_contact_in_manyheads_6month'],
            'is_top10_contact_in_manyheads_3month'=>$str['info_check']['is_top10_contact_in_manyheads_3month'],
            'is_called_by_collection_1month'=>$str['info_check']['is_called_by_collection_1month'],
            'is_contact3_called_6month'=>$str['info_check']['is_contact3_called_6month'],
            'is_net_age_over_3month'=>$str['info_check']['is_net_age_over_3month'],
            'is_mobile_status_active'=>$str['info_check']['is_mobile_status_active'],
            'is_called_by_collection_3month'=>$str['info_check']['is_called_by_collection_3month'],
            'is_called_by_collection_6month'=>$str['info_check']['is_called_by_collection_6month'],
            'is_contact1_called_6month'=>$str['info_check']['is_contact1_called_6month'],
            'is_home_tel_called_6month'=>$str['info_check']['is_home_tel_called_6month'],
            'is_contact5_called_6month'=>$str['info_check']['is_contact5_called_6month'],
            'is_net_addr_call_addr_1month'=>$str['info_check']['is_net_addr_call_addr_1month'],
            'is_identity_code_valid'=>$str['info_check']['is_identity_code_valid'],
            'is_net_addr_call_addr_6month'=>$str['info_check']['is_net_addr_call_addr_6month'],
            'ctime'=>time(),
        );
        M('info_check','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['info_check']);
        $add = array(
            'mobile'=>$mobile,
            'risk_contact_info_score'=>$str['behavior_score']['risk_contact_info_score'],
            'base_info_score'=>$str['behavior_score']['base_info_score'],
            'bill_info_score'=>$str['behavior_score']['bill_info_score'],
            'multapply_score'=>$str['behavior_score']['multapply_score'],
            'total_score'=>$str['behavior_score']['total_score'],
            'call_info_score'=>$str['behavior_score']['call_info_score'],
            'ctime'=>time(),
        );
        M('behavior_score','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['behavior_score']);
        $add = array(
            'mobile'=>$mobile,
            'black_top10_contact_carloan_blacklist_count_ratio'=>$str['contact_blacklist_analysis']['black_top10_contact_carloan_blacklist_count_ratio'],
            'black_top10_contact_fakemobile_count_ratio'=>$str['contact_blacklist_analysis']['black_top10_contact_fakemobile_count_ratio'],
            'black_top10_contact_over2_count_ratio'=>$str['contact_blacklist_analysis']['black_top10_contact_over2_count_ratio'],
            'black_top10_contact_paymentfraud_count_ratio'=>$str['contact_blacklist_analysis']['black_top10_contact_paymentfraud_count_ratio'],
            'black_top10_contact_discreditrepay_count_ratio'=>$str['contact_blacklist_analysis']['black_top10_contact_discreditrepay_count_ratio'],
            'black_top10_contact_total_count_ratio'=>$str['contact_blacklist_analysis']['black_top10_contact_total_count_ratio'],
            'black_top10_contact_creditcrack_count_ratio'=>$str['contact_blacklist_analysis']['black_top10_contact_creditcrack_count_ratio'],
            'black_top10_contact_studentloans_overdue_count_ratio'=>$str['contact_blacklist_analysis']['black_top10_contact_studentloans_overdue_count_ratio'],
            'black_top10_contact_scalping_count_ratio'=>$str['contact_blacklist_analysis']['black_top10_contact_scalping_count_ratio'],
            'ctime'=>time(),
        );
        M('contact_blacklist_analysis','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['contact_blacklist_analysis']);
        $add = array(
            'mobile'=>$mobile,
            'manyheads_top10_contact_recent6month_partnercode_count_avg'=>$str['contact_manyheads_analysis']['manyheads_top10_contact_recent6month_partnercode_count_avg'],
            'manyheads_top10_contact_recent6month_partnercode_count_over2'=>$str['contact_manyheads_analysis']['manyheads_top10_contact_recent6month_partnercode_count_over2'],
            'manyheads_top10_contact_recent1month_partnercode_count_avg'=>$str['contact_manyheads_analysis']['manyheads_top10_contact_recent1month_partnercode_count_avg'],
            'manyheads_top10_contact_recent3month_partnercode_count_over2'=>$str['contact_manyheads_analysis']['manyheads_top10_contact_recent3month_partnercode_count_over2'],
            'manyheads_top10_contact_recent6month_partnercode_count_max'=>$str['contact_manyheads_analysis']['manyheads_top10_contact_recent6month_partnercode_count_max'],
            'manyheads_top10_contact_recent3month_partnercode_count_max'=>$str['contact_manyheads_analysis']['manyheads_top10_contact_recent3month_partnercode_count_max'],
            'manyheads_top10_contact_recent1month_partnercode_count_max'=>$str['contact_manyheads_analysis']['manyheads_top10_contact_recent1month_partnercode_count_max'],
            'manyheads_top10_contact_recent1month_have_partnercode_count'=>$str['contact_manyheads_analysis']['manyheads_top10_contact_recent1month_have_partnercode_count'],
            'manyheads_top10_contact_recent3month_partnercode_count_avg'=>$str['contact_manyheads_analysis']['manyheads_top10_contact_recent3month_partnercode_count_avg'],
            'manyheads_top10_contact_recent3month_have_partnercode_count'=>$str['contact_manyheads_analysis']['manyheads_top10_contact_recent3month_have_partnercode_count'],
            'manyheads_top10_contact_recent6month_have_partnercode_count'=>$str['contact_manyheads_analysis']['manyheads_top10_contact_recent6month_have_partnercode_count'],
            'manyheads_top10_contact_recent1month_partnercode_count_over2'=>$str['contact_manyheads_analysis']['manyheads_top10_contact_recent1month_partnercode_count_over2'],
        );
        M('contact_manyheads_analysis','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['contact_manyheads_analysis']);
        $add = array(
            'mobile'=>$mobile,
            'creditscore_top10_contact_count'=>$str['contact_creditscore_analysis']['creditscore_top10_contact_count'],
            'creditscore_top10_contact_median'=>$str['contact_creditscore_analysis']['creditscore_top10_contact_median'],
            'creditscore_top10_contact_avg'=>$str['contact_creditscore_analysis']['creditscore_top10_contact_avg'],
            'creditscore_top10_contact_min'=>$str['contact_creditscore_analysis']['creditscore_top10_contact_min'],
            'creditscore_top10_contact_max'=>$str['contact_creditscore_analysis']['creditscore_top10_contact_max'],
            'ctime'=>time(),
        );
        M('contact_creditscore_analysis','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['contact_creditscore_analysis']);
        foreach ($str['contact_suspect_collection_analysis'] as $k=>$v){
            $add = array(
                'mobile'=>$mobile,
                'call_count_passive_1month'=>$v['call_count_passive_1month'],
                'call_time_active_1month'=>$v['call_time_active_1month'],
                'contact_count_active_3month'=>$v['contact_count_active_3month'],
                'contact_count_active_6month'=>$v['contact_count_active_6month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'msg_count_3month'=>$v['msg_count_3month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'msg_count_6month'=>$v['msg_count_6month'],
                'contact_count_passive_6month'=>$v['contact_count_passive_6month'],
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
                'contact_count_passive_3month'=>$v['contact_count_passive_3month'],
                'call_count_3month'=>$v['call_count_3month'],
                'risk_type'=>$v['risk_type'],
                'contact_count_1month'=>$v['contact_count_1month'],
                'call_count_6month'=>$v['call_count_6month'],
                'call_count_active_1month'=>$v['call_count_active_1month'],
                'contact_count_active_1month'=>$v['contact_count_active_1month'],
                'call_time_passive_1month'=>$v['call_time_passive_1month'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'contact_count_passive_1month'=>$v['contact_count_passive_1month'],
                'contact_count_3month'=>$v['contact_count_3month'],
                'contact_count_6month'=>$v['contact_count_6month'],
                'msg_count_1month'=>$v['msg_count_1month'],
                'ctime'=>time(),
            );
            $addnum[$k] = $add;
        }
        M('contact_suspect_collection_analysis','',C('DB2_ZX'))->addALL($addnum);
        $add = array(
            'mobile'=>$mobile,
            'call_count_holiday_3month'=>$str['emergency_contact2_detail']['call_count_holiday_3month'],
            'call_count_holiday_6month'=>$str['emergency_contact2_detail']['call_count_holiday_6month'],
            'call_count_active_6month'=>$str['emergency_contact2_detail']['call_count_active_6month'],
            'call_time_3month'=>$str['emergency_contact2_detail']['call_time_3month'],
            'msg_count_3month'=>$str['emergency_contact2_detail']['msg_count_3month'],
            'call_time_passive_6month'=>$str['emergency_contact2_detail']['call_time_passive_6month'],
            'call_time_1month'=>$str['emergency_contact2_detail']['call_time_1month'],
            'call_count_active_3month'=>$str['emergency_contact2_detail']['call_count_active_3month'],
            'call_time_6month'=>$str['emergency_contact2_detail']['call_time_6month'],
            'contact_type'=>$str['emergency_contact2_detail']['contact_type'],
            'call_count_late_night_3month'=>$str['emergency_contact2_detail']['call_count_late_night_3month'],
            'call_count_late_night_6month'=>$str['emergency_contact2_detail']['call_count_late_night_6month'],
            'call_count_passive_6month'=>$str['emergency_contact2_detail']['call_count_passive_6month'],
            'call_time_active_6month'=>$str['emergency_contact2_detail']['call_time_active_6month'],
            'msg_count_6month'=>$str['emergency_contact2_detail']['msg_count_6month'],
            'call_count_work_time_6month'=>$str['emergency_contact2_detail']['call_count_work_time_6month'],
            'first_time_call_6month'=>strtotime($str['emergency_contact2_detail']['first_time_call_6month']),
            'call_time_active_3month'=>$str['emergency_contact2_detail']['call_time_active_3month'],
            'call_count_passive_3month'=>$str['emergency_contact2_detail']['call_count_passive_3month'],
            'call_count_3month'=>$str['emergency_contact2_detail']['call_count_3month'],
            'contact_name'=>$str['emergency_contact2_detail']['contact_name'],
            'contact_relation'=>$str['emergency_contact2_detail']['contact_relation'],
            'call_count_work_time_3month'=>$str['emergency_contact2_detail']['call_count_work_time_3month'],
            'call_count_workday_3month'=>$str['emergency_contact2_detail']['call_count_workday_3month'],
            'call_count_6month'=>$str['emergency_contact2_detail']['call_count_6month'],
            'call_count_offwork_time_3month'=>$str['emergency_contact2_detail']['call_count_offwork_time_3month'],
            'call_count_offwork_time_6month'=>$str['emergency_contact2_detail']['call_count_offwork_time_6month'],
            'contact_number'=>$str['emergency_contact2_detail']['contact_number'],
            'contact_area'=>$str['emergency_contact2_detail']['contact_area'],
            'call_count_1week'=>$str['emergency_contact2_detail']['call_count_1week'],
            'contact_seq_no'=>$str['emergency_contact2_detail']['contact_seq_no'],
            'is_whole_day_call_3month'=>$str['emergency_contact2_detail']['is_whole_day_call_3month'],
            'call_count_1month'=>$str['emergency_contact2_detail']['call_count_1month'],
            'call_time_passive_3month'=>$str['emergency_contact2_detail']['call_time_passive_3month'],
            'is_whole_day_call_6month'=>$str['emergency_contact2_detail']['is_whole_day_call_6month'],
            'call_count_workday_6month'=>$str['emergency_contact2_detail']['call_count_workday_6month'],
            'last_time_call_6month'=>strtotime($str['emergency_contact2_detail']['last_time_call_6month']),
            'msg_count_1month'=>$str['emergency_contact2_detail']['msg_count_1month'],
        );
//        $has_emergency_contact1_detail =M('emergency_contact1_detail','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
//        if($has_emergency_contact1_detail){
//            M('emergency_contact1_detail','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
//        }
        M('emergency_contact1_detail','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['emergency_contact2_detail']);
        foreach ($str['carrier_consumption_stats_per_month'] as $k=>$v){
            $add = array(
                'mobile'=>$mobile,
                'consume_amount'=>$v['consume_amount'],
                'recharge_amount'=>$v['recharge_amount'],
                'month'=>strtotime($v['month']),
                'recharge_count'=>$v['recharge_count'],
            );
            $addnum[]=$add;
        }
        $has_carrier_consumption_stats_per_month =M('carrier_consumption_stats_per_month','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_carrier_consumption_stats_per_month){
            M('carrier_consumption_stats_per_month','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('carrier_consumption_stats_per_month','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['carrier_consumption_stats_per_month']);
        foreach ($str['finance_contact_stats'] as $k=>$v){
            $add = array(
                'mobile'=>$mobile,
                'call_count_3month'=>$v['call_count_3month'],
                'contact_count_1month'=>$v['contact_count_1month'],
                'call_count_6month'=>$v['call_count_6month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'msg_count_3month'=>$v['msg_count_3month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'contact_type'=>$v['contact_type'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'msg_count_6month'=>$v['msg_count_6month'],
                'contact_count_3month'=>$v['contact_count_3month'],
                'contact_count_6month'=>$v['contact_count_6month'],
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
            );
            $addnum[]=$add;
        }
        $has_finance_contact_stats =M('finance_contact_stats','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_finance_contact_stats){
            M('finance_contact_stats','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('finance_contact_stats','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['finance_contact_stats']);
        $add = array(
            'mobile'=>$mobile,
            'emergency_contact3_analysis_6month'=>$str['behavior_analysis']['emergency_contact3_analysis_6month'],
            'late_night_analysis_6month'=>$str['behavior_analysis']['late_night_analysis_6month'],
            'call_120_analysis_6month'=>$str['behavior_analysis']['call_120_analysis_6month'],
            'emergency_contact4_analysis_6month'=>$str['behavior_analysis']['emergency_contact4_analysis_6month'],
            'call_lawyer_analysis_6month'=>$str['behavior_analysis']['call_lawyer_analysis_6month'],
            'emergency_contact2_analysis_6month'=>$str['behavior_analysis']['emergency_contact2_analysis_6month'],
            'mutual_number_analysis_6month'=>$str['behavior_analysis']['mutual_number_analysis_6month'],
            'loan_contact_analysis_6month'=>$str['behavior_analysis']['loan_contact_analysis_6month'],
            'emergency_contact5_analysis_6month'=>$str['behavior_analysis']['emergency_contact5_analysis_6month'],
            'emergency_contact1_analysis_6month'=>$str['behavior_analysis']['emergency_contact1_analysis_6month'],
            'collection_contact_analysis_6month'=>$str['behavior_analysis']['collection_contact_analysis_6month'],
            'call_110_analysis_6month'=>$str['behavior_analysis']['call_110_analysis_6month'],
            'mobile_net_age_analysis'=>$str['behavior_analysis']['mobile_net_age_analysis'],
            'mobile_silence_analysis_6month'=>$str['behavior_analysis']['mobile_silence_analysis_6month'],
            'call_macau_analysis_6month'=>$str['behavior_analysis']['call_macau_analysis_6month'],
        );
        $has_behavior_analysis =M('behavior_analysis','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_behavior_analysis){
            M('behavior_analysis','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('behavior_analysis','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['behavior_analysis']);
        foreach ($str['risk_contact_detail'] as $k=>$v){
            $add = array(
                'mobile'=>$mobile,
                'call_count_holiday_3month'=>$v['call_count_holiday_3month'],
                'call_count_holiday_6month'=>$v['call_count_holiday_6month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'msg_count_3month'=>$v['msg_count_3month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'contact_type'=>$v['contact_type'],
                'call_count_late_night_3month'=>$v['call_count_late_night_3month'],
                'call_count_late_night_6month'=>$v['call_count_late_night_6month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'msg_count_6month'=>$v['msg_count_6month'],
                'call_count_work_time_6month'=>$v['call_count_work_time_6month'],
                'first_time_call_6month'=>strtotime($v['first_time_call_6month']),
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
                'call_count_3month'=>$v['call_count_3month'],
                'contact_name'=>$v['contact_name'],
                'contact_relation'=>$v['contact_relation'],
                'call_count_work_time_3month'=>$v['call_count_work_time_3month'],
                'call_count_workday_3month'=>$v['call_count_workday_3month'],
                'call_count_6month'=>$v['call_count_6month'],
                'call_count_offwork_time_3month'=>$v['call_count_offwork_time_3month'],
                'call_count_offwork_time_6month'=>$v['call_count_offwork_time_6month'],
                'contact_number'=>$v['contact_number'],
                'contact_area'=>$v['contact_area'],
                'call_count_1week'=>$v['call_count_1week'],
                'contact_seq_no'=>$v['contact_seq_no'],
                'is_whole_day_call_3month'=>$v['is_whole_day_call_3month'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'is_whole_day_call_6month'=>$v['is_whole_day_call_6month'],
                'call_count_workday_6month'=>$v['call_count_workday_6month'],
                'last_time_call_6month'=>strtotime($v['last_time_call_6month']),
                'msg_count_1month'=>$v['msg_count_1month'],
            );
            $addnum[] = $add;
        }
        $has_risk_contact_detail =M('risk_contact_detail','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_risk_contact_detail){
            M('risk_contact_detail','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('risk_contact_detail','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['risk_contact_detail']);
        $add = array(
            'mobile'=>$mobile,
            'call_count_holiday_3month'=>$str['all_contact_stats']['call_count_holiday_3month'],
            'call_count_holiday_6month'=>$str['all_contact_stats']['call_count_holiday_6month'],
            'call_count_call_time_over10min_6month'=>$str['all_contact_stats']['call_count_call_time_over10min_6month'],
            'contact_count_active_3month'=>$str['all_contact_stats']['contact_count_active_3month'],
            'contact_count_active_6month'=>$str['all_contact_stats']['contact_count_active_6month'],
            'call_count_active_6month'=>$str['all_contact_stats']['call_count_active_6month'],
            'call_time_3month'=>$str['all_contact_stats']['call_time_3month'],
            'msg_count_3month'=>$str['all_contact_stats']['msg_count_3month'],
            'call_time_1month'=>$str['all_contact_stats']['call_time_1month'],
            'call_time_passive_6month'=>$str['all_contact_stats']['call_time_passive_6month'],
            'call_count_active_3month'=>$str['all_contact_stats']['call_count_active_3month'],
            'call_time_6month'=>$str['all_contact_stats']['call_time_6month'],
            'call_count_late_night_3month'=>$str['all_contact_stats']['call_count_late_night_3month'],
            'call_count_late_night_6month'=>$str['all_contact_stats']['call_count_late_night_6month'],
            'call_count_passive_6month'=>$str['all_contact_stats']['call_count_passive_6month'],
            'call_time_active_6month'=>$str['all_contact_stats']['call_time_active_6month'],
            'msg_count_6month'=>$str['all_contact_stats']['msg_count_6month'],
            'contact_count_passive_6month'=>$str['all_contact_stats']['contact_count_passive_6month'],
            'call_count_work_time_6month'=>$str['all_contact_stats']['call_count_work_time_6month'],
            'call_count_call_time_5min10min_6month'=>$str['all_contact_stats']['call_count_call_time_5min10min_6month'],
            'call_time_active_3month'=>$str['all_contact_stats']['call_time_active_3month'],
            'contact_count_passive_3month'=>$str['all_contact_stats']['contact_count_passive_3month'],
            'call_count_passive_3month'=>$str['all_contact_stats']['call_count_passive_3month'],
            'call_count_3month'=>$str['all_contact_stats']['call_count_3month'],
            'contact_count_1month'=>$str['all_contact_stats']['contact_count_1month'],
            'call_count_work_time_3month'=>$str['all_contact_stats']['call_count_work_time_3month'],
            'call_count_workday_3month'=>$str['all_contact_stats']['call_count_workday_3month'],
            'call_count_6month'=>$str['all_contact_stats']['call_count_6month'],
            'call_count_offwork_time_3month'=>$str['all_contact_stats']['call_count_offwork_time_3month'],
            'call_count_offwork_time_6month'=>$str['all_contact_stats']['call_count_offwork_time_6month'],
            'contact_count_mutual_3month'=>$str['all_contact_stats']['contact_count_mutual_3month'],
            'call_count_1month'=>$str['all_contact_stats']['call_count_1month'],
            'call_time_passive_3month'=>$str['all_contact_stats']['call_time_passive_3month'],
            'call_count_call_time_less1min_6month'=>$str['all_contact_stats']['call_count_call_time_less1min_6month'],
            'contact_count_3month'=>$str['all_contact_stats']['contact_count_3month'],
            'contact_count_call_count_over10_3month'=>$str['all_contact_stats']['contact_count_call_count_over10_3month'],
            'call_count_workday_6month'=>$str['all_contact_stats']['call_count_workday_6month'],
            'contact_count_call_count_over10_6month'=>$str['all_contact_stats']['contact_count_call_count_over10_6month'],
            'contact_count_6month'=>$str['all_contact_stats']['contact_count_6month'],
            'contact_count_mutual_6month'=>$str['all_contact_stats']['contact_count_mutual_6month'],
            'call_count_call_time_1min5min_6month'=>$str['all_contact_stats']['call_count_call_time_1min5min_6month'],
        );
        $has_all_contact_stats =M('all_contact_stats','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_all_contact_stats){
            M('all_contact_stats','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('all_contact_stats','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['all_contact_stats']);
        foreach ($str['all_contact_detail'] as $k=>$v){
            $add=array(
                'mobile'=>$mobile,
                'call_count_holiday_3month'=>$v['call_count_holiday_3month'],
                'call_count_holiday_6month'=>$v['call_count_holiday_6month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'msg_count_3month'=>$v['msg_count_3month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'contact_type'=>$v['contact_type'],
                'call_count_late_night_3month'=>$v['call_count_late_night_3month'],
                'call_count_late_night_6month'=>$v['call_count_late_night_6month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'msg_count_6month'=>$v['msg_count_6month'],
                'call_count_work_time_6month'=>$v['call_count_work_time_6month'],
                'first_time_call_6month'=>strtotime($v['first_time_call_6month']),
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
                'call_count_3month'=>$v['call_count_3month'],
                'contact_name'=>$v['contact_name'],
                'contact_relation'=>$v['contact_relation'],
                'call_count_work_time_3month'=>$v['call_count_work_time_3month'],
                'call_count_workday_3month'=>$v['call_count_workday_3month'],
                'call_count_6month'=>$v['call_count_6month'],
                'call_count_offwork_time_3month'=>$v['call_count_offwork_time_3month'],
                'call_count_offwork_time_6month'=>$v['call_count_offwork_time_6month'],
                'contact_number'=>$v['contact_number'],
                'contact_area'=>$v['contact_area'],
                'call_count_1week'=>$v['call_count_1week'],
                'contact_seq_no'=>$v['contact_seq_no'],
                'is_whole_day_call_3month'=>$v['is_whole_day_call_3month'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'is_whole_day_call_6month'=>$v['is_whole_day_call_6month'],
                'call_count_workday_6month'=>$v['call_count_workday_6month'],
                'last_time_call_6month'=>strtotime($v['last_time_call_6month']),
                'msg_count_1month'=>$v['msg_count_1month'],
            );
            $addnum[]=$add;

        }
        $has_all_contact_detail =M('all_contact_detail','',C('NTH'))->where(['mobile'=>$mobile])->getField('id');
        if($has_all_contact_detail){
            M('all_contact_detail','',C('NTH'))->where(['mobile'=>$mobile])->delete();
        }
        M('all_contact_detail','',C('NTH'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['all_contact_detail']);
        $add = array(
            'mobile'=>$mobile,
            't_0'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_0'],
            't_1'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_1'],
            't_2'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_2'],
            't_3'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_3'],
            't_4'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_4'],
            't_5'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_5'],
            't_6'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_6'],
            't_7'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_7'],
            't_8'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_8'],
            't_9'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_9'],
            't_10'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_10'],
            't_11'=>$str['call_duration_stats_2hour']['call_duration_workday_6month']['t_11'],
        );
        $has_call_duration_workday_6month =M('call_duration_workday_6month','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_call_duration_workday_6month){
            M('call_duration_workday_6month','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('call_duration_workday_6month','',C('DB2_ZX'))->add($add);
        $add = array(
            'mobile'=>$mobile,
            't_0'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_0'],
            't_1'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_1'],
            't_2'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_2'],
            't_3'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_3'],
            't_4'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_4'],
            't_5'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_5'],
            't_6'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_6'],
            't_7'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_7'],
            't_8'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_8'],
            't_9'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_9'],
            't_10'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_10'],
            't_11'=>$str['call_duration_stats_2hour']['call_duration_holiday_6month']['t_11'],
        );
        $has_call_duration_holiday_6month =M('call_duration_holiday_6month','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_call_duration_holiday_6month){
            M('call_duration_holiday_6month','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('call_duration_holiday_6month','',C('DB2_ZX'))->add($add);
        $add = array(
            'mobile'=>$mobile,
            't_0'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_0'],
            't_1'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_1'],
            't_2'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_2'],
            't_3'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_3'],
            't_4'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_4'],
            't_5'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_5'],
            't_6'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_6'],
            't_7'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_7'],
            't_8'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_8'],
            't_9'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_9'],
            't_10'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_10'],
            't_11'=>$str['call_duration_stats_2hour']['call_duration_holiday_3month']['t_11'],
        );
        $has_call_duration_holiday_3month =M('call_duration_holiday_3month','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_call_duration_holiday_3month){
            M('call_duration_holiday_3month','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('call_duration_holiday_3month','',C('DB2_ZX'))->add($add);
        $add = array(
            'mobile'=>$mobile,
            't_0'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_0'],
            't_1'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_1'],
            't_2'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_2'],
            't_3'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_3'],
            't_4'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_4'],
            't_5'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_5'],
            't_6'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_6'],
            't_7'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_7'],
            't_8'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_8'],
            't_9'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_9'],
            't_10'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_10'],
            't_11'=>$str['call_duration_stats_2hour']['call_duration_workday_3month']['t_11'],
        );
        $has_call_duration_workday_3month =M('call_duration_workday_3month','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_call_duration_workday_3month){
            M('call_duration_workday_3month','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('call_duration_workday_3month','',C('DB2_ZX'))->add($add);
        unset($add);
        unset($str['call_duration_stats_2hour']);
        foreach ($str['all_contact_stats_per_month'] as $k=>$v){
            $add=array(
                'mobile'=>$mobile,
                'call_count_active'=>$v['call_count_active'],
                'call_count_passive'=>$v['call_count_passive'],
                'contact_count'=>$v['contact_count'],
                'call_time'=>$v['call_time'],
                'call_count_call_time_1min5min'=>$v['call_count_call_time_1min5min'],
                'contact_count_call_count_over10'=>$v['contact_count_call_count_over10'],
                'contact_count_active'=>$v['contact_count_active'],
                'call_count_call_time_less1min'=>$v['call_count_call_time_less1min'],
                'call_count_call_time_over10min'=>$v['call_count_call_time_over10min'],
                'call_count_offwork_time'=>$v['call_count_offwork_time'],
                'call_count_work_time'=>$v['call_count_work_time'],
                'contact_count_mutual'=>$v['contact_count_mutual'],
                'month'=>strtotime($v['month']),
                'call_time_passive'=>$v['call_time_passive'],
                'call_count_late_night'=>$v['call_count_late_night'],
                'call_count'=>$v['call_count'],
                'call_count_call_time_5min10min'=>$v['call_count_call_time_5min10min'],
                'call_time_active'=>$v['call_time_active'],
                'contact_count_passive'=>$v['contact_count_passive'],
                'msg_count'=>$v['msg_count'],
            );
            $addnum[]=$add;
        }
        $has_all_contact_stats_per_month =M('all_contact_stats_per_month','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_all_contact_stats_per_month){
            M('all_contact_stats_per_month','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('all_contact_stats_per_month','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['all_contact_stats_per_month']);
        foreach ($str['risk_contact_stats'] as $k=>$v){
            $add= array(
                'mobile'=>$mobile,
                'call_count_3month'=>$v['call_count_3month'],
                'risk_type'=>$v['risk_type'],
                'contact_count_1month'=>$v['contact_count_1month'],
                'call_count_6month'=>$v['call_count_6month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'msg_count_3month'=>$v['msg_count_3month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'msg_count_6month'=>$v['msg_count_6month'],
                'contact_count_3month'=>$v['contact_count_3month'],
                'contact_count_6month'=>$v['contact_count_6month'],
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
            );
            $addnum[]=$add;
        }
        $has_risk_contact_stats =M('risk_contact_stats','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_risk_contact_stats){
            M('risk_contact_stats','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('risk_contact_stats','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['risk_contact_stats']);
        foreach ($str['finance_contact_detail'] as $k=>$v){
            $add = array(
                'mobile'=>$mobile,
                'call_count_holiday_3month'=>$v['call_count_holiday_3month'],
                'call_count_holiday_6month'=>$v['call_count_holiday_6month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'msg_count_3month'=>$v['msg_count_3month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'contact_type'=>$v['contact_type'],
                'call_count_late_night_3month'=>$v['call_count_late_night_3month'],
                'call_count_late_night_6month'=>$v['call_count_late_night_6month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'msg_count_6month'=>$v['msg_count_6month'],
                'call_count_work_time_6month'=>$v['call_count_work_time_6month'],
                'first_time_call_6month'=>strtotime($v['first_time_call_6month']),
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
                'call_count_3month'=>$v['call_count_3month'],
                'contact_name'=>$v['contact_name'],
                'contact_relation'=>$v['contact_relation'],
                'call_count_work_time_3month'=>$v['call_count_work_time_3month'],
                'call_count_workday_3month'=>$v['call_count_workday_3month'],
                'call_count_6month'=>$v['call_count_6month'],
                'call_count_offwork_time_3month'=>$v['call_count_offwork_time_3month'],
                'call_count_offwork_time_6month'=>$v['call_count_offwork_time_6month'],
                'contact_number'=>$v['contact_number'],
                'contact_area'=>$v['contact_area'],
                'call_count_1week'=>$v['call_count_1week'],
                'contact_seq_no'=>$v['contact_seq_no'],
                'is_whole_day_call_3month'=>$v['is_whole_day_call_3month'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'is_whole_day_call_6month'=>$v['is_whole_day_call_6month'],
                'call_count_workday_6month'=>$v['call_count_workday_6month'],
                'last_time_call_6month'=>strtotime($v['last_time_call_6month']),
                'msg_count_1month'=>$v['msg_count_1month'],
            );
            $addnum[]=$add;
        }
        $has_finance_contact_detail =M('finance_contact_detail','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_finance_contact_detail){
            M('finance_contact_detail','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('finance_contact_detail','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['finance_contact_detail']);
        foreach ($str['call_area_stats_per_city'] as $k=>$v){
            $add= array(
                'mobile'=>$mobile,
                'call_count_holiday_3month'=>$v['call_count_holiday_3month'],
                'call_count_holiday_6month'=>$v['call_count_holiday_6month'],
                'active_day_1call_6month'=>$v['active_day_1call_6month'],
                'active_day_1call_3month'=>$v['active_day_1call_3month'],
                'active_day_1call_active_3month'=>$v['active_day_1call_active_3month'],
                'call_count_active_6month'=>$v['call_count_active_6month'],
                'call_time_3month'=>$v['call_time_3month'],
                'call_time_1month'=>$v['call_time_1month'],
                'call_time_passive_6month'=>$v['call_time_passive_6month'],
                'call_count_active_3month'=>$v['call_count_active_3month'],
                'call_time_6month'=>$v['call_time_6month'],
                'call_count_passive_6month'=>$v['call_count_passive_6month'],
                'call_time_active_6month'=>$v['call_time_active_6month'],
                'max_continue_active_day_1call_1month'=>$v['max_continue_active_day_1call_1month'],
                'active_day_1call_active_6month'=>$v['active_day_1call_active_6month'],
                'continue_active_day_over3_1call_6month'=>$v['continue_active_day_over3_1call_6month'],
                'call_area_seq_no'=>$v['call_area_seq_no'],
                'call_time_active_3month'=>$v['call_time_active_3month'],
                'call_count_passive_3month'=>$v['call_count_passive_3month'],
                'call_count_3month'=>$v['call_count_3month'],
                'call_count_workday_3month'=>$v['call_count_workday_3month'],
                'call_count_6month'=>$v['call_count_6month'],
                'continue_active_day_over3_1call_3month'=>$v['continue_active_day_over3_1call_3month'],
                'continue_active_day_over1_1call_6month'=>$v['continue_active_day_over1_1call_6month'],
                'max_continue_active_day_1call_3month'=>$v['max_continue_active_day_1call_3month'],
                'max_continue_active_day_1call_6month'=>$v['max_continue_active_day_1call_6month'],
                'continue_active_day_over1_1call_3month'=>$v['continue_active_day_over1_1call_3month'],
                'call_area_city'=>$v['call_area_city'],
                'active_day_1call_1month'=>$v['active_day_1call_1month'],
                'call_count_1month'=>$v['call_count_1month'],
                'call_time_passive_3month'=>$v['call_time_passive_3month'],
                'continue_active_day_over3_1call_1month'=>$v['continue_active_day_over3_1call_1month'],
                'call_count_workday_6month'=>$v['call_count_workday_6month'],
                'continue_active_day_over1_1call_1month'=>$v['continue_active_day_over1_1call_1month'],
                'active_day_1call_active_1month'=>$v['active_day_1call_active_1month'],
            );
            $addnum[]=$add;
        }
        $has_call_area_stats_per_city =M('call_area_stats_per_city','',C('DB2_ZX'))->where(['mobile'=>$mobile])->getField('id');
        if($has_call_area_stats_per_city){
            M('call_area_stats_per_city','',C('DB2_ZX'))->where(['mobile'=>$mobile])->delete();
        }
        M('call_area_stats_per_city','',C('DB2_ZX'))->addALL($addnum);
        unset($add);
        unset($addnum);
        unset($str['call_area_stats_per_city']);
        $this->return=['ret'=>'1001','code'=>'success'];
    }
    function post2($url, $data){//file_get_content

        $postdata = http_build_query(
            $data
        );
        $opts = array('http' =>
            array(
                'method'  => 'POST',
                'header'  => 'Content-type: application/x-www-form-urlencoded',
                'content' => $postdata
            )
        );
        $context = stream_context_create($opts);
        $result = file_get_contents($url, false, $context);
        return $result;
    }
}